Fix pipe types
This commit is contained in:
parent
b59794f423
commit
fff952cb1a
2 changed files with 13 additions and 20 deletions
|
@ -1,7 +1,6 @@
|
||||||
package techreborn.client.render.parts;
|
package techreborn.client.render.parts;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||||
|
@ -12,16 +11,12 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import techreborn.parts.fluidPipes.EnumFluidPipeTypes;
|
import techreborn.parts.fluidPipes.EnumFluidPipeTypes;
|
||||||
import techreborn.parts.powerCables.EnumCableType;
|
import techreborn.parts.powerCables.EnumCableType;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by modmuss50 on 04/03/2016.
|
* Created by modmuss50 on 04/03/2016.
|
||||||
*/
|
*/
|
||||||
public class ClientPartModelBakery
|
public class ClientPartModelBakery
|
||||||
{
|
{
|
||||||
|
|
||||||
public static HashMap<EnumCableType, TextureAtlasSprite> textureMap = new HashMap<>();
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||||
public void onModelBake(ModelBakeEvent event)
|
public void onModelBake(ModelBakeEvent event)
|
||||||
|
@ -29,8 +24,8 @@ public class ClientPartModelBakery
|
||||||
for (EnumCableType type : EnumCableType.values())
|
for (EnumCableType type : EnumCableType.values())
|
||||||
{
|
{
|
||||||
event.getModelRegistry().putObject(
|
event.getModelRegistry().putObject(
|
||||||
new ModelResourceLocation("techreborn:cable#type=" + type.getName().toLowerCase()),
|
new ModelResourceLocation("techreborn:cable", "type=" + type.getName().toLowerCase()),
|
||||||
new RenderCablePart());
|
new RenderCablePart(type));
|
||||||
}
|
}
|
||||||
for(EnumFluidPipeTypes type : EnumFluidPipeTypes.values()){
|
for(EnumFluidPipeTypes type : EnumFluidPipeTypes.values()){
|
||||||
event.getModelRegistry().putObject(
|
event.getModelRegistry().putObject(
|
||||||
|
@ -46,7 +41,6 @@ public class ClientPartModelBakery
|
||||||
for (EnumCableType type : EnumCableType.values())
|
for (EnumCableType type : EnumCableType.values())
|
||||||
{
|
{
|
||||||
event.getMap().registerSprite(new ResourceLocation(type.textureName));
|
event.getMap().registerSprite(new ResourceLocation(type.textureName));
|
||||||
|
|
||||||
}
|
}
|
||||||
for(EnumFluidPipeTypes type : EnumFluidPipeTypes.values()){
|
for(EnumFluidPipeTypes type : EnumFluidPipeTypes.values()){
|
||||||
event.getMap().registerSprite(new ResourceLocation(type.textureName));
|
event.getMap().registerSprite(new ResourceLocation(type.textureName));
|
||||||
|
|
|
@ -19,19 +19,21 @@ import java.util.List;
|
||||||
public class RenderCablePart implements IBakedModel
|
public class RenderCablePart implements IBakedModel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
EnumCableType type;
|
||||||
private FaceBakery faceBakery = new FaceBakery();
|
private FaceBakery faceBakery = new FaceBakery();
|
||||||
|
private TextureAtlasSprite texture;
|
||||||
|
|
||||||
|
public RenderCablePart(EnumCableType type)
|
||||||
|
{
|
||||||
|
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(type.textureName);
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand)
|
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand)
|
||||||
{
|
{
|
||||||
TextureAtlasSprite texture;
|
type = blockState.getValue(CableMultipart.TYPE);
|
||||||
EnumCableType type = blockState.getValue(CableMultipart.TYPE);
|
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(type.textureName);
|
||||||
if(ClientPartModelBakery.textureMap.containsKey(type)){
|
|
||||||
texture = ClientPartModelBakery.textureMap.get(type);
|
|
||||||
} else {
|
|
||||||
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(type.textureName);
|
|
||||||
ClientPartModelBakery.textureMap.put(type, texture);
|
|
||||||
}
|
|
||||||
ArrayList<BakedQuad> list = new ArrayList<>();
|
ArrayList<BakedQuad> list = new ArrayList<>();
|
||||||
BlockFaceUV uv = new BlockFaceUV(new float[] { 0.0F, 0.0F, 16.0F, 16.0F }, 0);
|
BlockFaceUV uv = new BlockFaceUV(new float[] { 0.0F, 0.0F, 16.0F, 16.0F }, 0);
|
||||||
BlockPartFace face = new BlockPartFace(null, 0, "", uv);
|
BlockPartFace face = new BlockPartFace(null, 0, "", uv);
|
||||||
|
@ -101,10 +103,7 @@ public class RenderCablePart implements IBakedModel
|
||||||
@Override
|
@Override
|
||||||
public TextureAtlasSprite getParticleTexture()
|
public TextureAtlasSprite getParticleTexture()
|
||||||
{
|
{
|
||||||
if(ClientPartModelBakery.textureMap.containsKey(EnumCableType.COPPER)){
|
return texture;
|
||||||
return ClientPartModelBakery.textureMap.get(EnumCableType.COPPER);
|
|
||||||
}
|
|
||||||
return Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue