Gui fixes, 393

This commit is contained in:
modmuss50 2019-02-22 14:02:04 +00:00
parent 06632be822
commit d68c65641d
20 changed files with 189 additions and 452 deletions

View file

@ -85,7 +85,8 @@ public enum EGui implements IMachineGuiHandler {
@Override
public void open(EntityPlayer player, BlockPos pos, World world) {
if(!world.isRemote){
player.openGui(TechReborn.INSTANCE, this.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
throw new UnsupportedOperationException("fix opening guis");
//player.openGui(TechReborn.INSTANCE, this.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
}
}

View file

@ -28,6 +28,7 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonExtended;
import reborncore.common.network.NetworkManager;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.client.gui.builder.widget.GuiButtonUpDown;
@ -73,17 +74,15 @@ public class GuiAESU extends GuiBase {
builder.drawMultiEnergyBar(this, 81, 28, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX, mouseY, 0, layer);
buttons.add(new GuiButtonUpDown(300, 121, 79, this, layer));
buttons.add(new GuiButtonUpDown(301, 121 + 12, 79, this, layer));
buttons.add(new GuiButtonUpDown(302, 121 + 24, 79, this, layer));
buttons.add(new GuiButtonUpDown(303, 121 + 36, 79, this, layer));
buttons.add(new GuiButtonUpDown(300, 121, 79, this, layer).clickHandler(this::onClick));
buttons.add(new GuiButtonUpDown(301, 121 + 12, 79, this, layer).clickHandler(this::onClick));
buttons.add(new GuiButtonUpDown(302, 121 + 24, 79, this, layer).clickHandler(this::onClick));
buttons.add(new GuiButtonUpDown(303, 121 + 36, 79, this, layer).clickHandler(this::onClick));
}
@Override
public void actionPerformed(final GuiButton button) throws IOException {
super.actionPerformed(button);
public void onClick(GuiButtonExtended button, Double x, Double y){
if (button.id >= 300 && button.id <= 303) {
NetworkManager.sendToServer(ServerboundPackets.createPacketAesu(button.id, tile));
}
}
}
}

View file

@ -32,6 +32,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonExtended;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.common.network.NetworkManager;
import techreborn.packets.ServerboundPackets;
@ -103,11 +104,11 @@ public class GuiAutoCrafting extends GuiBase {
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
if (isPointInRect(145, 4, 20, 12, mouseX, mouseY)) {
NetworkManager.sendToServer(ServerboundPackets.createPacketAutoCraftingTableLock(tileAutoCraftingTable, !tileAutoCraftingTable.locked));
return;
return true;
}
super.mouseClicked(mouseX, mouseY, mouseButton);
return super.mouseClicked(mouseX, mouseY, mouseButton);
}
}

View file

@ -32,6 +32,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.ClientProxy;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonExtended;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.client.multiblock.Multiblock;
import reborncore.client.multiblock.MultiblockRenderEvent;
@ -89,18 +90,16 @@ public class GuiBlastFurnace extends GuiBase {
builder.drawBigHeatBar(this, 31, 71, tile.getCachedHeat(), 3230, layer);
if (hasMultiBlock) {
addHologramButton(4, 4, 212, layer);
addHologramButton(4, 4, 212, layer).clickHandler(this::onClick);
} else {
builder.drawMultiblockMissingBar(this, layer);
addHologramButton(76, 56, 212, layer);
addHologramButton(76, 56, 212, layer).clickHandler(this::onClick);
builder.drawHologramButton(this, 76, 56, mouseX, mouseY, layer);
}
builder.drawMultiEnergyBar(this, 9, 19, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX, mouseY, 0, layer);
}
@Override
public void actionPerformed(final GuiButton button) throws IOException {
super.actionPerformed(button);
public void onClick(GuiButtonExtended button, Double x, Double y){
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
{

View file

@ -32,6 +32,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.ClientProxy;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonExtended;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.client.multiblock.Multiblock;
import reborncore.client.multiblock.MultiblockRenderEvent;
@ -81,20 +82,18 @@ public class GuiDistillationTower extends GuiBase {
builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 55, 40, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
if (tile.getMutliBlock()) {
addHologramButton(6, 4, 212, layer);
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
builder.drawHologramButton(this, 6, 4, mouseX, mouseY, layer);
} else {
builder.drawMultiblockMissingBar(this, layer);
addHologramButton(76, 56, 212, layer);
addHologramButton(76, 56, 212, layer).clickHandler(this::onClick);
builder.drawHologramButton(this, 76, 56, mouseX, mouseY, layer);
}
builder.drawMultiEnergyBar(this, 9, 19, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX, mouseY, 0, layer);
}
@Override
public void actionPerformed(final GuiButton button) throws IOException {
super.actionPerformed(button);
public void onClick(GuiButtonExtended button, Double x, Double y){
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
{

View file

@ -31,6 +31,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.ClientProxy;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonExtended;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.client.multiblock.Multiblock;
import reborncore.client.multiblock.MultiblockRenderEvent;
@ -93,19 +94,17 @@ public class GuiFluidReplicator extends GuiBase {
builder.drawTank(this, 99, 25, mouseX, mouseY, tile.tank.getFluid(), tile.tank.getCapacity(), tile.tank.isEmpty(), layer);
builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
if (tile.getMultiBlock()) {
addHologramButton(6, 4, 212, layer);
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
} else {
builder.drawMultiblockMissingBar(this, layer);
addHologramButton(76, 56, 212, layer);
addHologramButton(76, 56, 212, layer).clickHandler(this::onClick);
builder.drawHologramButton(this, 76, 56, mouseX, mouseY, layer);
}
builder.drawMultiEnergyBar(this, 9, 19, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX, mouseY, 0, layer);
}
// GuiScreen
@Override
public void actionPerformed(final GuiButton button) throws IOException {
super.actionPerformed(button);
public void onClick(GuiButtonExtended button, Double x, Double y){
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
{

View file

@ -31,6 +31,7 @@ import net.minecraft.util.math.BlockPos;
import org.apache.commons.lang3.tuple.Pair;
import reborncore.ClientProxy;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonExtended;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.client.multiblock.Multiblock;
import reborncore.client.multiblock.MultiblockRenderEvent;
@ -80,14 +81,14 @@ public class GuiFusionReactor extends GuiBase {
builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 55, 51, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 105, 51, mouseX, mouseY, GuiBuilder.ProgressDirection.LEFT, layer);
if (tile.getCoilStatus() > 0) {
addHologramButton(6, 4, 212, layer);
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
drawCentredString(tile.getStateString(), 20, Color.BLUE.darker().getRGB(), layer);
if(tile.state == 2){
drawCentredString( PowerSystem.getLocaliszedPowerFormatted((int) tile.getPowerChange()) + "/t", 30, Color.GREEN.darker().getRGB(), layer);
}
} else {
builder.drawMultiblockMissingBar(this, layer);
addHologramButton(76, 56, 212, layer);
addHologramButton(76, 56, 212, layer).clickHandler(this::onClick);
builder.drawHologramButton(this, 76, 56, mouseX, mouseY, layer);
Optional<Pair<Integer, Integer>> stackSize = getCoilStackCount();
@ -111,10 +112,8 @@ public class GuiFusionReactor extends GuiBase {
builder.drawMultiEnergyBar(this, 9, 19, (int) this.tile.getEnergy(), (int) this.tile.getMaxPower(), mouseX, mouseY, 0, layer);
}
@Override
public void actionPerformed(final GuiButton button) throws IOException {
super.actionPerformed(button);
public void onClick(GuiButtonExtended button, Double x, Double y){
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
updateMultiBlockRender();

View file

@ -31,6 +31,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
import reborncore.ClientProxy;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonExtended;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.client.multiblock.Multiblock;
import reborncore.client.multiblock.MultiblockRenderEvent;
@ -85,19 +86,17 @@ public class GuiImplosionCompressor extends GuiBase {
builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 71, 40, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
if (tile.getMutliBlock()) {
addHologramButton(6, 4, 212, layer);
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
} else {
builder.drawMultiblockMissingBar(this, layer);
addHologramButton(76, 56, 212, layer);
addHologramButton(76, 56, 212, layer).clickHandler(this::onClick);
builder.drawHologramButton(this, 76, 56, mouseX, mouseY, layer);
}
builder.drawMultiEnergyBar(this, 9, 19, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX, mouseY, 0, layer);
}
@Override
public void actionPerformed(final GuiButton button) throws IOException {
super.actionPerformed(button);
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY){
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
{

View file

@ -32,6 +32,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.ClientProxy;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonExtended;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.client.multiblock.Multiblock;
import reborncore.client.multiblock.MultiblockRenderEvent;
@ -91,18 +92,16 @@ public class GuiIndustrialGrinder extends GuiBase {
builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 105, 47, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
builder.drawTank(this, 53, 25, mouseX, mouseY, tile.tank.getFluid(), tile.tank.getCapacity(), tile.tank.isEmpty(), layer);
if (tile.getMultiBlock()) {
addHologramButton(6, 4, 212, layer);
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
} else {
builder.drawMultiblockMissingBar(this, layer);
addHologramButton(76, 56, 212, layer);
addHologramButton(76, 56, 212, layer).clickHandler(this::onClick);
builder.drawHologramButton(this, 76, 56, mouseX, mouseY, layer);
}
builder.drawMultiEnergyBar(this, 9, 19, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX, mouseY, 0, layer);
}
@Override
public void actionPerformed(final GuiButton button) throws IOException {
super.actionPerformed(button);
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY){
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
{

View file

@ -32,6 +32,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import reborncore.ClientProxy;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonExtended;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.client.multiblock.Multiblock;
import reborncore.client.multiblock.MultiblockRenderEvent;
@ -89,18 +90,16 @@ public class GuiIndustrialSawmill extends GuiBase {
builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 105, 47, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
builder.drawTank(this, 53, 25, mouseX, mouseY, tile.tank.getFluid(), tile.tank.getCapacity(), tile.tank.isEmpty(), layer);
if (tile.getMutliBlock()) {
addHologramButton(6, 4, 212, layer);
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
} else {
builder.drawMultiblockMissingBar(this, layer);
addHologramButton(76, 56, 212, layer);
addHologramButton(76, 56, 212, layer).clickHandler(this::onClick);
builder.drawHologramButton(this, 76, 56, mouseX, mouseY, layer);
}
builder.drawMultiEnergyBar(this, 9, 19, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX, mouseY, 0, layer);
}
@Override
public void actionPerformed(final GuiButton button) throws IOException {
super.actionPerformed(button);
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY){
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
{

View file

@ -30,6 +30,7 @@ import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import reborncore.client.gui.builder.widget.GuiButtonExtended;
import techreborn.items.ItemManual;
import java.awt.*;
@ -57,8 +58,8 @@ public class GuiManual extends GuiScreen {
@Override
public void initGui() {
buttons.add(new GuiButton(1, (width / 2 - 30), (height / 2 - (guiHeight / 4)) + 17, 60, 20, I18n.format("techreborn.manual.wikibtn")));
buttons.add(new GuiButton(2, (width / 2 - 30), (height / 2) + 22, 60, 20, I18n.format("techreborn.manual.discordbtn")));
buttons.add(new GuiButtonExtended(1, (width / 2 - 30), (height / 2 - (guiHeight / 4)) + 17, 60, 20, I18n.format("techreborn.manual.wikibtn")).clickHandler(this::onClick));
buttons.add(new GuiButtonExtended(2, (width / 2 - 30), (height / 2) + 22, 60, 20, I18n.format("techreborn.manual.discordbtn")).clickHandler(this::onClick));
}
@Override
@ -73,8 +74,7 @@ public class GuiManual extends GuiScreen {
super.render(mouseX, mouseY, partialTicks);
}
@Override
protected void actionPerformed(GuiButton button) {
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY){
switch (button.id) {
case 1:
mc.displayGuiScreen(new GuiConfirmOpenLink(this, "http://wiki.techreborn.ovh", 1, false));
@ -86,7 +86,7 @@ public class GuiManual extends GuiScreen {
}
@Override
public void confirmClicked(boolean result, int id) {
public void confirmResult(boolean result, int id) {
switch(id) {
case 1:
if(result == true) {

View file

@ -75,11 +75,12 @@ public class GuiRollingMachine extends GuiBase {
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) {
if(isPointInRect(130, 4, 20, 12, mouseX, mouseY)){
NetworkManager.sendToServer(ServerboundPackets.createPacketRollingMachineLock(rollingMachine, !rollingMachine.locked));
return;
return true;
}
super.mouseClicked(mouseX, mouseY, mouseButton);
return super.mouseClicked(mouseX, mouseY, mouseButton);
}
}

View file

@ -30,6 +30,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.math.BlockPos;
import reborncore.ClientProxy;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonExtended;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.client.multiblock.Multiblock;
import reborncore.client.multiblock.MultiblockRenderEvent;
@ -81,18 +82,16 @@ public class GuiVacuumFreezer extends GuiBase {
builder.drawProgressBar(this, tile.getProgressScaled(100), 100, 76, 48, mouseX, mouseY, GuiBuilder.ProgressDirection.RIGHT, layer);
if (tile.getMultiBlock()) {
addHologramButton(6, 4, 212, layer);
addHologramButton(6, 4, 212, layer).clickHandler(this::onClick);
} else {
builder.drawMultiblockMissingBar(this, layer);
addHologramButton(76, 56, 212, layer);
addHologramButton(76, 56, 212, layer).clickHandler(this::onClick);
builder.drawHologramButton(this, 76, 56, mouseX, mouseY, layer);
}
builder.drawMultiEnergyBar(this, 9, 19, (int) tile.getEnergy(), (int) tile.getMaxPower(), mouseX, mouseY, 0, layer);
}
@Override
public void actionPerformed(final GuiButton button) throws IOException {
super.actionPerformed(button);
public void onClick(GuiButtonExtended button, Double mouseX, Double mouseY){
if (button.id == 212 && GuiBase.slotConfigType == SlotConfigType.NONE) {
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
{

View file

@ -49,14 +49,13 @@ import techreborn.items.DynamicCell;
import javax.annotation.Nullable;
import java.awt.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.*;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
//TODO 1.13 very broken, look at ModelDynBucket for help porting this fully
@OnlyIn(Dist.CLIENT)
public class ModelDynamicCell implements IModel {
public class ModelDynamicCell implements IUnbakedModel {
public static final ModelDynamicCell MODEL = new ModelDynamicCell(
new ResourceLocation("techreborn:items/cell_cover"),
@ -69,8 +68,8 @@ public class ModelDynamicCell implements IModel {
private static final float SOUTH_Z_FLUID = 8.4f / 16f;
public static void init() {
ModelLoader.setCustomMeshDefinition(TRContent.CELL, stack -> MODEL_LOCATION);
ModelBakery.registerItemVariants(TRContent.CELL, MODEL_LOCATION);
// ModelLoader.setCustomMeshDefinition(TRContent.CELL, stack -> MODEL_LOCATION);
// ModelBakery.registerItemVariants(TRContent.CELL, MODEL_LOCATION);
ModelLoaderRegistry.registerLoader(new DynamicCellLoader());
}
@ -94,22 +93,22 @@ public class ModelDynamicCell implements IModel {
}
@Override
public Collection<ResourceLocation> getTextures() {
public Collection<ResourceLocation> getTextures(Function<ResourceLocation, IUnbakedModel> modelGetter, Set<String> missingTextureErrors) {
return ImmutableList.of(baseTexture, emptyTexture);
}
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
public IBakedModel bake(Function<ResourceLocation, IUnbakedModel> modelGetter, Function<ResourceLocation, TextureAtlasSprite> spriteGetter, IModelState state, boolean uvlock, VertexFormat format) {
ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state);
TRSRTransformation transform = state.apply(Optional.empty()).orElse(TRSRTransformation.identity());
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
builder.addAll(new ItemLayerModel(ImmutableList.of(baseTexture)).bake(transform, format, bakedTextureGetter).getQuads(null, null, 0L));
builder.addAll(new ItemLayerModel(ImmutableList.of(baseTexture)).bake(modelGetter, spriteGetter, state, uvlock, format).getQuads(null, null, new Random()));
ResourceLocation sprite = fluid != null ? fluid.getStill() : emptyTexture;
int color = fluid != null ? fluid.getColor() : Color.WHITE.getRGB();
TextureAtlasSprite fluidSprite = bakedTextureGetter.apply(sprite);
TextureAtlasSprite fluidSprite = spriteGetter.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, -1));
@ -117,9 +116,10 @@ public class ModelDynamicCell implements IModel {
}
}
return new BakedDynamicCell(builder.build(), this, bakedTextureGetter.apply(baseTexture), format, transformMap);
return new BakedDynamicCell(builder.build(), this, spriteGetter.apply(baseTexture), format, transformMap);
}
@Override
public IModelState getDefaultState() {
return TRSRTransformation.identity();
@ -133,7 +133,7 @@ public class ModelDynamicCell implements IModel {
}
@Override
public IModel loadModel(ResourceLocation modelLocation) {
public IUnbakedModel loadModel(ResourceLocation modelLocation) {
return MODEL;
}
@ -142,7 +142,7 @@ public class ModelDynamicCell implements IModel {
}
public static class BakedDynamicCell implements IBakedModel {
public static class BakedDynamicCell extends BakedItemModel {
private final List<BakedQuad> quads;
private final ModelDynamicCell parent;
@ -150,11 +150,12 @@ public class ModelDynamicCell implements IModel {
private final VertexFormat format;
private final ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transformMap;
public BakedDynamicCell(List<BakedQuad> quads,
public BakedDynamicCell(ImmutableList<BakedQuad> quads,
ModelDynamicCell parent,
TextureAtlasSprite particle,
VertexFormat format,
ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transformMap) {
super(quads, particle, transformMap, null /* TODO fix this */);
this.transformMap = transformMap;
this.quads = quads;
this.parent = parent;
@ -162,15 +163,6 @@ public class ModelDynamicCell implements IModel {
this.format = format;
}
@Override
public List<BakedQuad> getQuads(
@Nullable
IBlockState state,
@Nullable
EnumFacing side, long rand) {
return quads;
}
@Override
public boolean isAmbientOcclusion() {
return true;
@ -209,28 +201,28 @@ public class ModelDynamicCell implements IModel {
private final HashMap<String, IBakedModel> modelCache = new HashMap<>();
private final Function<ResourceLocation, TextureAtlasSprite> textureGetter = location ->
Minecraft.getInstance().getTextureMapBlocks().getAtlasSprite(location.toString());
// private final Function<ResourceLocation, TextureAtlasSprite> textureGetter = location ->
// Minecraft.getInstance().getTextureMapBlocks().getAtlasSprite(location.toString());
private OverrideHandler() {
super(ImmutableList.of());
}
// 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);
// }
}