Auto Format code
This commit is contained in:
parent
112b1657cf
commit
796df6c055
503 changed files with 12260 additions and 16291 deletions
|
@ -35,179 +35,180 @@ import java.util.List;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class ModelDynamicCell implements IModel {
|
||||
|
||||
public static final ModelDynamicCell MODEL = new ModelDynamicCell(
|
||||
new ResourceLocation("techreborn:items/cell_cover"),
|
||||
new ResourceLocation("techreborn:items/cell_empty")
|
||||
);
|
||||
public static final ModelDynamicCell MODEL = new ModelDynamicCell(
|
||||
new ResourceLocation("techreborn:items/cell_cover"),
|
||||
new ResourceLocation("techreborn:items/cell_empty")
|
||||
);
|
||||
|
||||
public static final ModelResourceLocation MODEL_LOCATION = new ModelResourceLocation(new ResourceLocation("techreborn", "dynamic_cell"), "default");
|
||||
public static final ModelResourceLocation MODEL_LOCATION = new ModelResourceLocation(new ResourceLocation("techreborn", "dynamic_cell"), "default");
|
||||
|
||||
private static final float NORTH_Z_FLUID = 7.6f / 16f;
|
||||
private static final float SOUTH_Z_FLUID = 8.4f / 16f;
|
||||
private static final float NORTH_Z_FLUID = 7.6f / 16f;
|
||||
private static final float SOUTH_Z_FLUID = 8.4f / 16f;
|
||||
|
||||
public static void init() {
|
||||
ModelLoader.setCustomMeshDefinition(ModItems.dynamicCell, stack -> MODEL_LOCATION);
|
||||
ModelBakery.registerItemVariants(ModItems.dynamicCell, MODEL_LOCATION);
|
||||
ModelLoaderRegistry.registerLoader(new DynamicCellLoader());
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
ModelLoader.setCustomMeshDefinition(ModItems.dynamicCell, stack -> MODEL_LOCATION);
|
||||
ModelBakery.registerItemVariants(ModItems.dynamicCell, MODEL_LOCATION);
|
||||
ModelLoaderRegistry.registerLoader(new DynamicCellLoader());
|
||||
}
|
||||
private final ResourceLocation baseTexture;
|
||||
private final ResourceLocation emptyTexture;
|
||||
private final Fluid fluid;
|
||||
|
||||
public ModelDynamicCell(ResourceLocation baseTexture, ResourceLocation emptyTexture) {
|
||||
this(baseTexture, emptyTexture, null);
|
||||
}
|
||||
|
||||
private final ResourceLocation baseTexture;
|
||||
private final ResourceLocation emptyTexture;
|
||||
private final Fluid fluid;
|
||||
public ModelDynamicCell(ResourceLocation baseTexture, ResourceLocation emptyTexture, Fluid fluid) {
|
||||
this.baseTexture = baseTexture;
|
||||
this.emptyTexture = emptyTexture;
|
||||
this.fluid = fluid;
|
||||
}
|
||||
|
||||
public ModelDynamicCell(ResourceLocation baseTexture, ResourceLocation emptyTexture) {
|
||||
this(baseTexture, emptyTexture, null);
|
||||
}
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
public ModelDynamicCell(ResourceLocation baseTexture, ResourceLocation emptyTexture, Fluid fluid) {
|
||||
this.baseTexture = baseTexture;
|
||||
this.emptyTexture = emptyTexture;
|
||||
this.fluid = fluid;
|
||||
}
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures() {
|
||||
return ImmutableList.of(baseTexture, emptyTexture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getTextures() {
|
||||
return ImmutableList.of(baseTexture, emptyTexture);
|
||||
}
|
||||
ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transformMap = IPerspectiveAwareModel.MapWrapper.getTransforms(state);
|
||||
TRSRTransformation transform = state.apply(Optional.<IModelPart>absent()).or(TRSRTransformation.identity());
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
builder.addAll(new ItemLayerModel(ImmutableList.of(baseTexture)).bake(transform, format, bakedTextureGetter).getQuads(null, null, 0L));
|
||||
|
||||
ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transformMap = IPerspectiveAwareModel.MapWrapper.getTransforms(state);
|
||||
TRSRTransformation transform = state.apply(Optional.<IModelPart>absent()).or(TRSRTransformation.identity());
|
||||
ResourceLocation sprite = fluid != null ? fluid.getStill() : emptyTexture;
|
||||
int color = fluid != null ? fluid.getColor() : Color.WHITE.getRGB();
|
||||
TextureAtlasSprite fluidSprite = bakedTextureGetter.apply(sprite);
|
||||
if (fluid != null) {
|
||||
if (fluidSprite != null) {
|
||||
builder.add(ItemTextureQuadConverter.genQuad(format, transform, 5, 2, 11, 14, NORTH_Z_FLUID, fluidSprite, EnumFacing.NORTH, color));
|
||||
builder.add(ItemTextureQuadConverter.genQuad(format, transform, 5, 2, 11, 14, SOUTH_Z_FLUID, fluidSprite, EnumFacing.SOUTH, color));
|
||||
}
|
||||
}
|
||||
|
||||
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
|
||||
builder.addAll(new ItemLayerModel(ImmutableList.of(baseTexture)).bake(transform, format, bakedTextureGetter).getQuads(null, null, 0L));
|
||||
return new BakedDynamicCell(builder.build(), this, bakedTextureGetter.apply(baseTexture), format, transformMap);
|
||||
}
|
||||
|
||||
ResourceLocation sprite = fluid != null ? fluid.getStill() : emptyTexture;
|
||||
int color = fluid != null ? fluid.getColor() : Color.WHITE.getRGB();
|
||||
TextureAtlasSprite fluidSprite = bakedTextureGetter.apply(sprite);
|
||||
if(fluid != null){
|
||||
if (fluidSprite != null) {
|
||||
builder.add(ItemTextureQuadConverter.genQuad(format, transform, 5, 2, 11, 14, NORTH_Z_FLUID, fluidSprite, EnumFacing.NORTH, color));
|
||||
builder.add(ItemTextureQuadConverter.genQuad(format, transform, 5, 2, 11, 14, SOUTH_Z_FLUID, fluidSprite, EnumFacing.SOUTH, color));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public IModelState getDefaultState() {
|
||||
return TRSRTransformation.identity();
|
||||
}
|
||||
|
||||
return new BakedDynamicCell(builder.build(), this, bakedTextureGetter.apply(baseTexture), format, transformMap);
|
||||
}
|
||||
public static class DynamicCellLoader implements ICustomModelLoader {
|
||||
|
||||
@Override
|
||||
public IModelState getDefaultState() {
|
||||
return TRSRTransformation.identity();
|
||||
}
|
||||
@Override
|
||||
public boolean accepts(ResourceLocation modelLocation) {
|
||||
return modelLocation.getResourceDomain().equals("techreborn") && modelLocation.getResourcePath().contains("dynamic_cell");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModel loadModel(ResourceLocation modelLocation) throws Exception {
|
||||
return MODEL;
|
||||
}
|
||||
|
||||
public static class DynamicCellLoader implements ICustomModelLoader {
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {}
|
||||
|
||||
@Override
|
||||
public boolean accepts(ResourceLocation modelLocation) {
|
||||
return modelLocation.getResourceDomain().equals("techreborn") && modelLocation.getResourcePath().contains("dynamic_cell");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IModel loadModel(ResourceLocation modelLocation) throws Exception {
|
||||
return MODEL;
|
||||
}
|
||||
public static class BakedDynamicCell implements IBakedModel {
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {}
|
||||
private final List<BakedQuad> quads;
|
||||
private final ModelDynamicCell parent;
|
||||
private final TextureAtlasSprite particle;
|
||||
private final VertexFormat format;
|
||||
private final ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transformMap;
|
||||
|
||||
}
|
||||
public BakedDynamicCell(List<BakedQuad> quads,
|
||||
ModelDynamicCell parent,
|
||||
TextureAtlasSprite particle,
|
||||
VertexFormat format,
|
||||
ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transformMap) {
|
||||
this.transformMap = transformMap;
|
||||
this.quads = quads;
|
||||
this.parent = parent;
|
||||
this.particle = particle;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public static class BakedDynamicCell implements IBakedModel{
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(
|
||||
@Nullable
|
||||
IBlockState state,
|
||||
@Nullable
|
||||
EnumFacing side, long rand) {
|
||||
return quads;
|
||||
}
|
||||
|
||||
private final List<BakedQuad> quads;
|
||||
private final ModelDynamicCell parent;
|
||||
private final TextureAtlasSprite particle;
|
||||
private final VertexFormat format;
|
||||
private final ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transformMap;
|
||||
@Override
|
||||
public boolean isAmbientOcclusion() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public BakedDynamicCell(List<BakedQuad> quads, ModelDynamicCell parent, TextureAtlasSprite particle, VertexFormat format, ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transformMap) {
|
||||
this.transformMap = transformMap;
|
||||
this.quads = quads;
|
||||
this.parent = parent;
|
||||
this.particle = particle;
|
||||
this.format = format;
|
||||
}
|
||||
@Override
|
||||
public boolean isGui3d() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
|
||||
return quads;
|
||||
}
|
||||
@Override
|
||||
public boolean isBuiltInRenderer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
return particle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms() {
|
||||
return ModelHelper.DEFAULT_ITEM_TRANSFORMS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return OVERRIDES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
return particle;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms() {
|
||||
return ModelHelper.DEFAULT_ITEM_TRANSFORMS;
|
||||
}
|
||||
public static final OverrideHandler OVERRIDES = new OverrideHandler();
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return OVERRIDES;
|
||||
}
|
||||
public static class OverrideHandler extends ItemOverrideList {
|
||||
|
||||
private final HashMap<String, IBakedModel> modelCache = new HashMap<>();
|
||||
|
||||
}
|
||||
private final Function<ResourceLocation, TextureAtlasSprite> textureGetter = location ->
|
||||
Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
|
||||
|
||||
private OverrideHandler() {
|
||||
super(ImmutableList.of());
|
||||
}
|
||||
|
||||
public static final OverrideHandler OVERRIDES = new OverrideHandler();
|
||||
|
||||
public static class OverrideHandler extends ItemOverrideList {
|
||||
|
||||
private final HashMap<String, IBakedModel> modelCache = new HashMap<>();
|
||||
|
||||
private final Function<ResourceLocation, TextureAtlasSprite> textureGetter = location ->
|
||||
Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
|
||||
|
||||
private OverrideHandler() {
|
||||
super(ImmutableList.of());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
|
||||
FluidStack fluidStack = DynamicCell.getFluidHandler(stack).getFluid();
|
||||
if(fluidStack == null) {
|
||||
//return default bucket
|
||||
return originalModel;
|
||||
}
|
||||
String name = fluidStack.getFluid().getName();
|
||||
if(!modelCache.containsKey(name)) {
|
||||
BakedDynamicCell bakedCell = (BakedDynamicCell) originalModel;
|
||||
ModelDynamicCell model = new ModelDynamicCell(bakedCell.parent.baseTexture, bakedCell.parent.emptyTexture, fluidStack.getFluid());
|
||||
modelCache.put(name, model.bake(new SimpleModelState(bakedCell.transformMap), bakedCell.format, textureGetter));
|
||||
}
|
||||
return modelCache.get(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
|
||||
FluidStack fluidStack = DynamicCell.getFluidHandler(stack).getFluid();
|
||||
if (fluidStack == null) {
|
||||
//return default bucket
|
||||
return originalModel;
|
||||
}
|
||||
String name = fluidStack.getFluid().getName();
|
||||
if (!modelCache.containsKey(name)) {
|
||||
BakedDynamicCell bakedCell = (BakedDynamicCell) originalModel;
|
||||
ModelDynamicCell model = new ModelDynamicCell(bakedCell.parent.baseTexture, bakedCell.parent.emptyTexture, fluidStack.getFluid());
|
||||
modelCache.put(name, model.bake(new SimpleModelState(bakedCell.transformMap), bakedCell.format, textureGetter));
|
||||
}
|
||||
return modelCache.get(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,26 +21,24 @@ import java.io.Reader;
|
|||
@SideOnly(Side.CLIENT)
|
||||
public class ModelHelper {
|
||||
|
||||
public static final ItemCameraTransforms DEFAULT_ITEM_TRANSFORMS = loadTransformFromJson(new ResourceLocation("minecraft:models/item/generated"));
|
||||
public static final ItemCameraTransforms HANDHELD_ITEM_TRANSFORMS = loadTransformFromJson(new ResourceLocation("minecraft:models/item/handheld"));
|
||||
public static final ItemCameraTransforms DEFAULT_ITEM_TRANSFORMS = loadTransformFromJson(new ResourceLocation("minecraft:models/item/generated"));
|
||||
public static final ItemCameraTransforms HANDHELD_ITEM_TRANSFORMS = loadTransformFromJson(new ResourceLocation("minecraft:models/item/handheld"));
|
||||
|
||||
public static ItemCameraTransforms loadTransformFromJson(ResourceLocation location) {
|
||||
try {
|
||||
|
||||
public static ItemCameraTransforms loadTransformFromJson(ResourceLocation location) {
|
||||
try {
|
||||
|
||||
return ModelBlock.deserialize(getReaderForResource(location)).getAllTransforms();
|
||||
} catch (IOException exception) {
|
||||
Core.logHelper.warn("Can't load resource " + location);
|
||||
exception.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Reader getReaderForResource(ResourceLocation location) throws IOException {
|
||||
ResourceLocation file = new ResourceLocation(location.getResourceDomain(), location.getResourcePath() + ".json");
|
||||
IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(file);
|
||||
return new BufferedReader(new InputStreamReader(iresource.getInputStream(), Charsets.UTF_8));
|
||||
}
|
||||
return ModelBlock.deserialize(getReaderForResource(location)).getAllTransforms();
|
||||
} catch (IOException exception) {
|
||||
Core.logHelper.warn("Can't load resource " + location);
|
||||
exception.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Reader getReaderForResource(ResourceLocation location) throws IOException {
|
||||
ResourceLocation file = new ResourceLocation(location.getResourceDomain(), location.getResourcePath() + ".json");
|
||||
IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(file);
|
||||
return new BufferedReader(new InputStreamReader(iresource.getInputStream(), Charsets.UTF_8));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,23 +15,19 @@ import techreborn.init.ModBlocks;
|
|||
/**
|
||||
* Created by Mark on 13/03/2016.
|
||||
*/
|
||||
public class RenderNukePrimed extends Render<EntityNukePrimed>
|
||||
{
|
||||
public class RenderNukePrimed extends Render<EntityNukePrimed> {
|
||||
|
||||
public RenderNukePrimed(RenderManager renderManager)
|
||||
{
|
||||
public RenderNukePrimed(RenderManager renderManager) {
|
||||
super(renderManager);
|
||||
this.shadowSize = 0.5F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRender(EntityNukePrimed entity, double x, double y, double z, float entityYaw, float partialTicks)
|
||||
{
|
||||
public void doRender(EntityNukePrimed entity, double x, double y, double z, float entityYaw, float partialTicks) {
|
||||
BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate((float) x, (float) y + 0.5F, (float) z);
|
||||
if ((float) entity.fuse - partialTicks + 1.0F < 10.0F)
|
||||
{
|
||||
if ((float) entity.fuse - partialTicks + 1.0F < 10.0F) {
|
||||
float f = 1.0F - ((float) entity.fuse - partialTicks + 1.0F) / 10.0F;
|
||||
f = MathHelper.clamp_float(f, 0.0F, 1.0F);
|
||||
f = f * f;
|
||||
|
@ -43,10 +39,9 @@ public class RenderNukePrimed extends Render<EntityNukePrimed>
|
|||
this.bindEntityTexture(entity);
|
||||
GlStateManager.translate(-0.5F, -0.5F, 0.5F);
|
||||
blockrendererdispatcher.renderBlockBrightness(ModBlocks.nuke.getDefaultState(),
|
||||
entity.getBrightness(partialTicks));
|
||||
entity.getBrightness(partialTicks));
|
||||
GlStateManager.translate(0.0F, 0.0F, 1.0F);
|
||||
if (entity.fuse / 5 % 2 == 0)
|
||||
{
|
||||
if (entity.fuse / 5 % 2 == 0) {
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 772);
|
||||
|
@ -54,7 +49,7 @@ public class RenderNukePrimed extends Render<EntityNukePrimed>
|
|||
GlStateManager.doPolygonOffset(-3.0F, -3.0F);
|
||||
GlStateManager.enablePolygonOffset();
|
||||
blockrendererdispatcher.renderBlockBrightness(
|
||||
ModBlocks.nuke.getDefaultState().withProperty(BlockNuke.OVERLAY, true), 1.0F);
|
||||
ModBlocks.nuke.getDefaultState().withProperty(BlockNuke.OVERLAY, true), 1.0F);
|
||||
GlStateManager.doPolygonOffset(0.0F, 0.0F);
|
||||
GlStateManager.disablePolygonOffset();
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
@ -66,8 +61,7 @@ public class RenderNukePrimed extends Render<EntityNukePrimed>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(EntityNukePrimed entity)
|
||||
{
|
||||
protected ResourceLocation getEntityTexture(EntityNukePrimed entity) {
|
||||
return TextureMap.LOCATION_BLOCKS_TEXTURE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,30 +10,25 @@ import techreborn.compat.ICompatModule;
|
|||
/**
|
||||
* Created by modmuss50 on 05/03/2016.
|
||||
*/
|
||||
public class ClientPartLoader implements ICompatModule
|
||||
{
|
||||
public class ClientPartLoader implements ICompatModule {
|
||||
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
MinecraftForge.EVENT_BUS.register(new ClientPartModelBakery());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLInitializationEvent event)
|
||||
{
|
||||
public void init(FMLInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverStarting(FMLServerStartingEvent event)
|
||||
{
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,35 +14,30 @@ import techreborn.parts.powerCables.EnumCableType;
|
|||
/**
|
||||
* Created by modmuss50 on 04/03/2016.
|
||||
*/
|
||||
public class ClientPartModelBakery
|
||||
{
|
||||
public class ClientPartModelBakery {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onModelBake(ModelBakeEvent event)
|
||||
{
|
||||
for (EnumCableType type : EnumCableType.values())
|
||||
{
|
||||
public void onModelBake(ModelBakeEvent event) {
|
||||
for (EnumCableType type : EnumCableType.values()) {
|
||||
event.getModelRegistry().putObject(
|
||||
new ModelResourceLocation("techreborn:cable", "type=" + type.getName().toLowerCase()),
|
||||
new RenderCablePart(type));
|
||||
new ModelResourceLocation("techreborn:cable", "type=" + type.getName().toLowerCase()),
|
||||
new RenderCablePart(type));
|
||||
}
|
||||
for(EnumFluidPipeTypes type : EnumFluidPipeTypes.values()){
|
||||
for (EnumFluidPipeTypes type : EnumFluidPipeTypes.values()) {
|
||||
event.getModelRegistry().putObject(
|
||||
new ModelResourceLocation("techreborn:fluidpipe#type=" + type.getName().toLowerCase()),
|
||||
new RenderFluidPipePart(type));
|
||||
new ModelResourceLocation("techreborn:fluidpipe#type=" + type.getName().toLowerCase()),
|
||||
new RenderFluidPipePart(type));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void textureStichEvent(TextureStitchEvent event)
|
||||
{
|
||||
for (EnumCableType type : EnumCableType.values())
|
||||
{
|
||||
public void textureStichEvent(TextureStitchEvent event) {
|
||||
for (EnumCableType type : EnumCableType.values()) {
|
||||
event.getMap().registerSprite(new ResourceLocation(type.textureName));
|
||||
}
|
||||
for(EnumFluidPipeTypes type : EnumFluidPipeTypes.values()){
|
||||
for (EnumFluidPipeTypes type : EnumFluidPipeTypes.values()) {
|
||||
event.getMap().registerSprite(new ResourceLocation(type.textureName));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import net.minecraft.client.renderer.block.model.*;
|
|||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
import reborncore.client.models.BakedModelUtils;
|
||||
import reborncore.common.misc.vecmath.Vecs3dCube;
|
||||
import techreborn.parts.powerCables.CableMultipart;
|
||||
|
@ -16,22 +15,19 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class RenderCablePart implements IBakedModel
|
||||
{
|
||||
public class RenderCablePart implements IBakedModel {
|
||||
|
||||
EnumCableType type;
|
||||
private FaceBakery faceBakery = new FaceBakery();
|
||||
private TextureAtlasSprite texture;
|
||||
|
||||
public RenderCablePart(EnumCableType type)
|
||||
{
|
||||
public RenderCablePart(EnumCableType type) {
|
||||
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(type.textureName);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand)
|
||||
{
|
||||
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand) {
|
||||
type = blockState.getValue(CableMultipart.TYPE);
|
||||
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(type.textureName);
|
||||
ArrayList<BakedQuad> list = new ArrayList<>();
|
||||
|
@ -40,81 +36,67 @@ public class RenderCablePart implements IBakedModel
|
|||
double thickness = type.cableThickness;
|
||||
double lastThickness = 16 - thickness;
|
||||
IExtendedBlockState state = (IExtendedBlockState) blockState;
|
||||
if (side != null)
|
||||
{
|
||||
if (side != null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, null, faceBakery);
|
||||
if (state != null)
|
||||
{
|
||||
if (state.getValue(CableMultipart.UP))
|
||||
{
|
||||
list, face, ModelRotation.X0_Y0, texture, null, faceBakery);
|
||||
if (state != null) {
|
||||
if (state.getValue(CableMultipart.UP)) {
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.UP, faceBakery);
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.UP, faceBakery);
|
||||
}
|
||||
if (state.getValue(CableMultipart.DOWN))
|
||||
{
|
||||
if (state.getValue(CableMultipart.DOWN)) {
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, 0.0, thickness, lastThickness, thickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.DOWN, faceBakery);
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.DOWN, faceBakery);
|
||||
}
|
||||
if (state.getValue(CableMultipart.NORTH))
|
||||
{
|
||||
if (state.getValue(CableMultipart.NORTH)) {
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y90, texture, EnumFacing.NORTH, faceBakery);
|
||||
face, ModelRotation.X0_Y90, texture, EnumFacing.NORTH, faceBakery);
|
||||
}
|
||||
if (state.getValue(CableMultipart.SOUTH))
|
||||
{
|
||||
if (state.getValue(CableMultipart.SOUTH)) {
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y270, texture, EnumFacing.SOUTH, faceBakery);
|
||||
list, face, ModelRotation.X0_Y270, texture, EnumFacing.SOUTH, faceBakery);
|
||||
}
|
||||
if (state.getValue(CableMultipart.EAST))
|
||||
{
|
||||
if (state.getValue(CableMultipart.EAST)) {
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(lastThickness, thickness, thickness, 16.0, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.EAST, faceBakery);
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.EAST, faceBakery);
|
||||
}
|
||||
if (state.getValue(CableMultipart.WEST))
|
||||
{
|
||||
if (state.getValue(CableMultipart.WEST)) {
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.WEST, faceBakery);
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.WEST, faceBakery);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
public boolean isAmbientOcclusion() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
{
|
||||
public boolean isGui3d() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer()
|
||||
{
|
||||
public boolean isBuiltInRenderer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
return texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms()
|
||||
{
|
||||
public ItemCameraTransforms getItemCameraTransforms() {
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
{
|
||||
public ItemOverrideList getOverrides() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import reborncore.client.models.BakedModelUtils;
|
|||
import reborncore.common.misc.vecmath.Vecs3dCube;
|
||||
import techreborn.parts.fluidPipes.EnumFluidPipeTypes;
|
||||
import techreborn.parts.fluidPipes.MultipartFluidPipe;
|
||||
import techreborn.parts.powerCables.EnumCableType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -22,134 +21,125 @@ import java.util.List;
|
|||
*/
|
||||
public class RenderFluidPipePart implements IBakedModel {
|
||||
|
||||
private FaceBakery faceBakery = new FaceBakery();
|
||||
private TextureAtlasSprite texture;
|
||||
EnumFluidPipeTypes type;
|
||||
private FaceBakery faceBakery = new FaceBakery();
|
||||
private TextureAtlasSprite texture;
|
||||
EnumFluidPipeTypes type;
|
||||
|
||||
public RenderFluidPipePart(EnumFluidPipeTypes type) {
|
||||
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(type.textureName);
|
||||
this.type = type;
|
||||
}
|
||||
public RenderFluidPipePart(EnumFluidPipeTypes type) {
|
||||
texture = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(type.textureName);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static void addCubeToList(Vecs3dCube cube, ArrayList<BakedQuad> list, BlockPartFace face,
|
||||
ModelRotation modelRotation, TextureAtlasSprite cubeTexture, EnumFacing dir, FaceBakery faceBakery)
|
||||
{
|
||||
BlockFaceUV uv = new BlockFaceUV(new float[] { (float) cube.getMinX(), (float) cube.getMinY(),
|
||||
(float) cube.getMaxX(), (float) cube.getMaxY() }, 0);
|
||||
face = new BlockPartFace(null, 0, "", uv);
|
||||
list.add(faceBakery.makeBakedQuad(
|
||||
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
||||
new Vector3f((float) cube.getMaxX(), (float) cube.getMinY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||
EnumFacing.DOWN, modelRotation, null, true, true));// down
|
||||
list.add(faceBakery.makeBakedQuad(
|
||||
new Vector3f((float) cube.getMinX(), (float) cube.getMaxY(), (float) cube.getMinZ()),
|
||||
new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||
EnumFacing.UP, modelRotation, null, true, true));// up
|
||||
list.add(faceBakery.makeBakedQuad(
|
||||
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
||||
new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||
EnumFacing.NORTH, modelRotation, null, true, true));// north
|
||||
list.add(faceBakery.makeBakedQuad(
|
||||
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMaxZ()),
|
||||
new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||
EnumFacing.SOUTH, modelRotation, null, true, true));// south
|
||||
list.add(faceBakery.makeBakedQuad(
|
||||
new Vector3f((float) cube.getMaxX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
||||
new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||
EnumFacing.EAST, modelRotation, null, true, true));// east
|
||||
list.add(faceBakery.makeBakedQuad(
|
||||
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
||||
new Vector3f((float) cube.getMinX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||
EnumFacing.WEST, modelRotation, null, true, true));// west
|
||||
}
|
||||
public static void addCubeToList(Vecs3dCube cube, ArrayList<BakedQuad> list, BlockPartFace face,
|
||||
ModelRotation modelRotation, TextureAtlasSprite cubeTexture, EnumFacing dir, FaceBakery faceBakery) {
|
||||
BlockFaceUV uv = new BlockFaceUV(new float[] { (float) cube.getMinX(), (float) cube.getMinY(),
|
||||
(float) cube.getMaxX(), (float) cube.getMaxY() }, 0);
|
||||
face = new BlockPartFace(null, 0, "", uv);
|
||||
list.add(faceBakery.makeBakedQuad(
|
||||
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
||||
new Vector3f((float) cube.getMaxX(), (float) cube.getMinY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||
EnumFacing.DOWN, modelRotation, null, true, true));// down
|
||||
list.add(faceBakery.makeBakedQuad(
|
||||
new Vector3f((float) cube.getMinX(), (float) cube.getMaxY(), (float) cube.getMinZ()),
|
||||
new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||
EnumFacing.UP, modelRotation, null, true, true));// up
|
||||
list.add(faceBakery.makeBakedQuad(
|
||||
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
||||
new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||
EnumFacing.NORTH, modelRotation, null, true, true));// north
|
||||
list.add(faceBakery.makeBakedQuad(
|
||||
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMaxZ()),
|
||||
new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||
EnumFacing.SOUTH, modelRotation, null, true, true));// south
|
||||
list.add(faceBakery.makeBakedQuad(
|
||||
new Vector3f((float) cube.getMaxX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
||||
new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||
EnumFacing.EAST, modelRotation, null, true, true));// east
|
||||
list.add(faceBakery.makeBakedQuad(
|
||||
new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
|
||||
new Vector3f((float) cube.getMinX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
|
||||
EnumFacing.WEST, modelRotation, null, true, true));// west
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand) {
|
||||
ArrayList<BakedQuad> list = new ArrayList<>();
|
||||
BlockFaceUV uv = new BlockFaceUV(new float[] { 0.0F, 0.0F, 16.0F, 16.0F }, 0);
|
||||
BlockPartFace face = new BlockPartFace(null, 0, "", uv);
|
||||
double thickness = MultipartFluidPipe.thickness;
|
||||
double lastThickness = 16 - thickness;
|
||||
IExtendedBlockState state = (IExtendedBlockState) blockState;
|
||||
if (side != null)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
boolean renderedConnection = false;
|
||||
if (state != null)
|
||||
{
|
||||
if (state.getValue(MultipartFluidPipe.UP))
|
||||
{
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.UP, faceBakery);
|
||||
renderedConnection = true;
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.DOWN))
|
||||
{
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, 0.0, thickness, lastThickness, thickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.DOWN, faceBakery);
|
||||
renderedConnection = true;
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.NORTH))
|
||||
{
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, 0.0, lastThickness, lastThickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.NORTH, faceBakery);
|
||||
renderedConnection = true;
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.SOUTH))
|
||||
{
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, 16.0),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.SOUTH, faceBakery);
|
||||
renderedConnection = false;
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.EAST))
|
||||
{
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, 16, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.EAST, faceBakery);
|
||||
renderedConnection = false;
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.WEST))
|
||||
{
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.WEST, faceBakery);
|
||||
renderedConnection = true;
|
||||
}
|
||||
if(!renderedConnection){
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, null, faceBakery);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState blockState, EnumFacing side, long rand) {
|
||||
ArrayList<BakedQuad> list = new ArrayList<>();
|
||||
BlockFaceUV uv = new BlockFaceUV(new float[] { 0.0F, 0.0F, 16.0F, 16.0F }, 0);
|
||||
BlockPartFace face = new BlockPartFace(null, 0, "", uv);
|
||||
double thickness = MultipartFluidPipe.thickness;
|
||||
double lastThickness = 16 - thickness;
|
||||
IExtendedBlockState state = (IExtendedBlockState) blockState;
|
||||
if (side != null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
boolean renderedConnection = false;
|
||||
if (state != null) {
|
||||
if (state.getValue(MultipartFluidPipe.UP)) {
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, lastThickness, thickness, lastThickness, 16.0, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.UP, faceBakery);
|
||||
renderedConnection = true;
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.DOWN)) {
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, 0.0, thickness, lastThickness, thickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.DOWN, faceBakery);
|
||||
renderedConnection = true;
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.NORTH)) {
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, 0.0, lastThickness, lastThickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.NORTH, faceBakery);
|
||||
renderedConnection = true;
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.SOUTH)) {
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, 16.0),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.SOUTH, faceBakery);
|
||||
renderedConnection = false;
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.EAST)) {
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, 16, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, EnumFacing.EAST, faceBakery);
|
||||
renderedConnection = false;
|
||||
}
|
||||
if (state.getValue(MultipartFluidPipe.WEST)) {
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(0.0, thickness, thickness, thickness, lastThickness, lastThickness), list,
|
||||
face, ModelRotation.X0_Y0, texture, EnumFacing.WEST, faceBakery);
|
||||
renderedConnection = true;
|
||||
}
|
||||
if (!renderedConnection) {
|
||||
BakedModelUtils.addCubeToList(new Vecs3dCube(thickness, thickness, thickness, lastThickness, lastThickness, lastThickness),
|
||||
list, face, ModelRotation.X0_Y0, texture, null, faceBakery);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isAmbientOcclusion() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isGui3d() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuiltInRenderer() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isBuiltInRenderer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
return texture;
|
||||
}
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
return texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms() {
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms() {
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue