Inital cable rendering

This only took 2 hours :/
This commit is contained in:
modmuss50 2016-03-05 10:48:13 +00:00
parent 0b04bb8c69
commit e3c150c06e
7 changed files with 77 additions and 35 deletions

View file

@ -0,0 +1,34 @@
package techreborn.client.render.parts;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import techreborn.compat.ICompatModule;
/**
* Created by Mark on 05/03/2016.
*/
public class ClientPartLoader implements ICompatModule {
@Override
public void preInit(FMLPreInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new ClientPartModelBakery());
}
@Override
public void init(FMLInitializationEvent event) {
}
@Override
public void postInit(FMLPostInitializationEvent event) {
}
@Override
public void serverStarting(FMLServerStartingEvent event) {
}
}

View file

@ -2,41 +2,21 @@ package techreborn.client.render.parts;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import techreborn.compat.ICompatModule;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import techreborn.parts.CableMultipart;
/**
* Created by Mark on 04/03/2016.
*/
public class ClientPartModelBakery implements ICompatModule {
public class ClientPartModelBakery {
@SubscribeEvent
@SideOnly(Side.CLIENT)
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onModelBake(ModelBakeEvent event){
event.modelRegistry.putObject(new ModelResourceLocation("techreborn:cable"), new RenderCablePart());
event.modelRegistry.putObject(new ModelResourceLocation("techreborn:cable#type=COPPER"), new RenderCablePart());
}
@Override
public void preInit(FMLPreInitializationEvent event) {
}
@Override
public void init(FMLInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(this);
}
@Override
public void postInit(FMLPostInitializationEvent event) {
}
@Override
public void serverStarting(FMLServerStartingEvent event) {
}
}

View file

@ -22,7 +22,7 @@ public class RenderCablePart implements ISmartMultipartModel {
private TextureAtlasSprite texture;
public RenderCablePart() {
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/iron_block");
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("fluxedredstone:blocks/cable_redstone");
}
@Override
@ -72,7 +72,7 @@ public class RenderCablePart implements ISmartMultipartModel {
@Override
public TextureAtlasSprite getParticleTexture() {
return null;
return texture;
}
@Override

View file

@ -5,6 +5,7 @@ import java.util.ArrayList;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.relauncher.Side;
import techreborn.client.render.parts.ClientPartLoader;
import techreborn.client.render.parts.ClientPartModelBakery;
import techreborn.compat.minetweaker.MinetweakerCompat;
import techreborn.compat.recipes.RecipesBiomesOPlenty;
@ -43,10 +44,10 @@ public class CompatManager {
registerCompact(RecipesBuildcraft.class, "BuildCraft|Builders");
registerCompact(RecipesThaumcraft.class, "Thaumcraft");
registerCompact(TechRebornParts.class, "mcmultipart");
registerCompact(ClientPartModelBakery.class, "mcmultipart", "@client");
registerCompact(ClientPartLoader.class, "mcmultipart", "@client");
}
public void registerCompact(Class<?> moduleClass, Object... objs) {
public void registerCompact(Class<? extends ICompatModule> moduleClass, Object... objs) {
boolean shouldLoad = ConfigTechReborn.config.get(ConfigTechReborn.CATEGORY_INTEGRATION, "Compat:" + moduleClass.getSimpleName(), true, "Should the " + moduleClass.getSimpleName() + " be loaded?").getBoolean(true);
if (ConfigTechReborn.config.hasChanged())
ConfigTechReborn.config.save();

View file

@ -6,6 +6,7 @@ import mcmultipart.multipart.*;
import net.minecraft.block.Block;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
@ -48,6 +49,7 @@ public class CableMultipart extends Multipart implements IOccludingPart, ISlotte
public static final IUnlistedProperty EAST = Properties.toUnlisted(PropertyBool.create("east"));
public static final IUnlistedProperty SOUTH = Properties.toUnlisted(PropertyBool.create("south"));
public static final IUnlistedProperty WEST = Properties.toUnlisted(PropertyBool.create("west"));
public static final IProperty TYPE = PropertyEnum.create("type", CableTypes.class);
public CableMultipart() {
connectedSides = new HashMap<>();
@ -470,13 +472,16 @@ public class CableMultipart extends Multipart implements IOccludingPart, ISlotte
.withProperty(NORTH, shouldConnectTo(EnumFacing.NORTH))
.withProperty(SOUTH, shouldConnectTo(EnumFacing.SOUTH))
.withProperty(WEST, shouldConnectTo(EnumFacing.WEST))
.withProperty(EAST, shouldConnectTo(EnumFacing.EAST));
.withProperty(EAST, shouldConnectTo(EnumFacing.EAST))
.withProperty(TYPE, CableTypes.COPPER);
}
@Override
public BlockState createBlockState() {
return new ExtendedBlockState(MCMultiPartMod.multipart,
new IProperty[0],
new IProperty[]{
TYPE
},
new IUnlistedProperty[]{
DOWN,
UP,

View file

@ -0,0 +1,22 @@
package techreborn.parts;
import net.minecraft.util.IStringSerializable;
/**
* Created by Mark on 05/03/2016.
*/
public enum CableTypes implements IStringSerializable {
COPPER("copper"),
TIN("tin");
private String friendlyName;
CableTypes(String friendlyName) {
this.friendlyName = friendlyName;
}
@Override
public String getName() {
return friendlyName;
}
}

View file

@ -27,7 +27,7 @@ public class TechRebornParts implements ICompatModule {
@Override
public void init(FMLInitializationEvent event) {
MultipartRegistry.registerPart(CableMultipart.class, "techreborn:cablepart");
MultipartRegistry.registerPart(CableMultipart.class, "techreborn:cable");
cables = new ItemCables();
GameRegistry.registerItem(cables, "cables");
}