Texture variations for walls.
This commit is contained in:
parent
a847e1827a
commit
816e13b8aa
41 changed files with 223 additions and 29 deletions
|
@ -8,11 +8,10 @@
|
|||
*/
|
||||
package wile.engineersdecor;
|
||||
|
||||
import wile.engineersdecor.detail.ModConfig;
|
||||
import wile.engineersdecor.detail.ExtItems;
|
||||
import wile.engineersdecor.detail.Networking;
|
||||
import wile.engineersdecor.detail.RecipeCondModSpecific;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import wile.engineersdecor.detail.*;
|
||||
import wile.engineersdecor.blocks.*;
|
||||
import wile.engineersdecor.items.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
|
@ -39,6 +38,7 @@ import net.minecraftforge.event.RegistryEvent;
|
|||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
|
@ -126,12 +126,16 @@ public class ModEngineersDecor
|
|||
|
||||
@SubscribeEvent
|
||||
public static void registerItems(final RegistryEvent.Register<Item> event)
|
||||
{ ModBlocks.registerItemBlocks(event); }
|
||||
{ ModBlocks.registerItemBlocks(event); ModItems.registerItems(event); }
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerRecipes(RegistryEvent.Register<IRecipe> event)
|
||||
{ ModRecipes.registerRecipes(event); }
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void registerModels(final ModelRegistryEvent event)
|
||||
{ ModBlocks.initModels(); }
|
||||
{ ModBlocks.initModels(); ModItems.initModels(); }
|
||||
}
|
||||
|
||||
public static final CreativeTabs CREATIVE_TAB_ENGINEERSDECOR = (new CreativeTabs("tabengineersdecor") {
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.block.*;
|
|||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockFaceShape;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -41,6 +42,7 @@ public class BlockDecorWall extends BlockDecor
|
|||
public static final PropertyBool EAST = BlockWall.EAST;
|
||||
public static final PropertyBool SOUTH = BlockWall.SOUTH;
|
||||
public static final PropertyBool WEST = BlockWall.WEST;
|
||||
public static final PropertyInteger TEXTURE_VARIANT = PropertyInteger.create("tvariant", 0, 7);
|
||||
|
||||
private static final double d_0 = 0.0d;
|
||||
private static final double d_1 = 1.0d;
|
||||
|
@ -165,12 +167,13 @@ public class BlockDecorWall extends BlockDecor
|
|||
boolean s = canWallConnectTo(world, pos, EnumFacing.SOUTH);
|
||||
boolean w = canWallConnectTo(world, pos, EnumFacing.WEST);
|
||||
boolean nopole = (n && s && !e && !w) || (!n && !s && e && w);
|
||||
return state.withProperty(UP,!nopole).withProperty(NORTH, n).withProperty(EAST, e).withProperty(SOUTH, s).withProperty(WEST, w);
|
||||
long prnd = pos.toLong(); prnd = (prnd>>29) ^ (prnd>>17) ^ (prnd>>9) ^ (prnd>>4) ^ pos.getX() ^ pos.getY() ^ pos.getZ();
|
||||
return state.withProperty(UP,!nopole).withProperty(NORTH, n).withProperty(EAST, e).withProperty(SOUTH, s).withProperty(WEST, w).withProperty(TEXTURE_VARIANT, ((int)prnd) & 0x7);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState()
|
||||
{ return new BlockStateContainer(this, new IProperty[] {UP, NORTH, EAST, WEST, SOUTH}); }
|
||||
{ return new BlockStateContainer(this, new IProperty[] {UP, NORTH, EAST, WEST, SOUTH, TEXTURE_VARIANT}); }
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
|
|
|
@ -14,11 +14,11 @@ import wile.engineersdecor.blocks.*;
|
|||
import net.minecraftforge.common.config.Config;
|
||||
import net.minecraftforge.common.config.ConfigManager;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@Config(modid = ModEngineersDecor.MODID)
|
||||
|
@ -253,6 +253,12 @@ public class ModConfig
|
|||
return false;
|
||||
}
|
||||
|
||||
public static final boolean isOptedOut(final @Nullable Item item)
|
||||
{
|
||||
if((item == null) || (optout == null)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static final void apply()
|
||||
{
|
||||
BlockDecorFurnace.BTileEntity.on_config(tweaks.furnace_smelting_speed_percent, tweaks.furnace_fuel_efficiency_percent, tweaks.furnace_boost_energy_consumption);
|
||||
|
|
|
@ -5,23 +5,43 @@
|
|||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* General handling auxiliaries for mod recipes.
|
||||
*
|
||||
* Credits/references:
|
||||
*
|
||||
* - Looked up how blusunrise did the ore-to-grit recipes in `blusunrize.immersiveengineering.common.IERecipes`.
|
||||
*/
|
||||
package wile.engineersdecor.detail;
|
||||
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import wile.engineersdecor.blocks.BlockDecorFurnace;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public class ModRecipes
|
||||
{
|
||||
public static final void registerRecipes(RegistryEvent.Register<IRecipe> event)
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
// Furnace
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Not a standard recipe, on-the-fly changable behaviour of the furnace.
|
||||
*/
|
||||
public static final void furnaceRecipeOverrideReset()
|
||||
{ BlockDecorFurnace.BRecipes.instance().reset(); }
|
||||
|
||||
/**
|
||||
* Not a standard recipe, on-the-fly changable behaviour of the furnace.
|
||||
*/
|
||||
public static final void furnaceRecipeOverrideSmeltsOresToNuggets()
|
||||
{
|
||||
try {
|
||||
|
|
51
1.12/src/main/java/wile/engineersdecor/items/ItemDecor.java
Normal file
51
1.12/src/main/java/wile/engineersdecor/items/ItemDecor.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* @file ItemDecor.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2018 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Basic item functionality for mod items.
|
||||
*/
|
||||
package wile.engineersdecor.items;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import wile.engineersdecor.detail.ModAuxiliaries;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemDecor extends Item
|
||||
{
|
||||
ItemDecor(String registryName)
|
||||
{
|
||||
super();
|
||||
setRegistryName(ModEngineersDecor.MODID, registryName);
|
||||
setTranslationKey(ModEngineersDecor.MODID + "." + registryName);
|
||||
setMaxStackSize(64);
|
||||
setCreativeTab(ModEngineersDecor.CREATIVE_TAB_ENGINEERSDECOR);
|
||||
setHasSubtypes(false);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void initModel()
|
||||
{
|
||||
ModelResourceLocation rc = new ModelResourceLocation(getRegistryName(),"inventory");
|
||||
ModelBakery.registerItemVariants(this, rc);
|
||||
ModelLoader.setCustomMeshDefinition(this, stack->rc);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag)
|
||||
{ ModAuxiliaries.Tooltip.addInformation(stack, world, tooltip, flag, true); }
|
||||
|
||||
}
|
63
1.12/src/main/java/wile/engineersdecor/items/ModItems.java
Normal file
63
1.12/src/main/java/wile/engineersdecor/items/ModItems.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* @file ModItems.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2018 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Definition and initialisation of items of this module.
|
||||
*/
|
||||
package wile.engineersdecor.items;
|
||||
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import wile.engineersdecor.detail.ModConfig;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ModItems
|
||||
{
|
||||
|
||||
private static final Item[] modItems = {
|
||||
};
|
||||
|
||||
private static final ArrayList<Item> registeredItems = new ArrayList<>();
|
||||
|
||||
@Nonnull
|
||||
public static List<Item> getRegisteredItems()
|
||||
{ return Collections.unmodifiableList(registeredItems); }
|
||||
|
||||
public static final void registerItems(RegistryEvent.Register<Item> event)
|
||||
{
|
||||
// Config based registry selection
|
||||
int num_registrations_skipped = 0;
|
||||
ArrayList<Item> allItems = new ArrayList<>();
|
||||
Collections.addAll(allItems, modItems);
|
||||
final boolean woor = ModConfig.isWithoutOptOutRegistration();
|
||||
for(Item e:allItems) {
|
||||
if((!woor) || (!ModConfig.isOptedOut(e))) {
|
||||
registeredItems.add(e);
|
||||
} else {
|
||||
++num_registrations_skipped;
|
||||
}
|
||||
}
|
||||
for(Item e:registeredItems) event.getRegistry().register(e);
|
||||
ModEngineersDecor.logger.info("Registered " + Integer.toString(registeredItems.size()) + " items.");
|
||||
if(num_registrations_skipped > 0) {
|
||||
ModEngineersDecor.logger.info("Skipped registration of " + num_registrations_skipped + " items.");
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static final void initModels()
|
||||
{
|
||||
for(Item e:registeredItems) {
|
||||
if(e instanceof ItemDecor) ((ItemDecor)e).initModel();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue