mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
Reconstructor Lens Rendering
This commit is contained in:
parent
4985f671a0
commit
abec9c81af
7 changed files with 117 additions and 14 deletions
|
@ -27,7 +27,7 @@ minecraft {
|
||||||
runDir = "idea"
|
runDir = "idea"
|
||||||
|
|
||||||
replaceIn "ModUtil.java"
|
replaceIn "ModUtil.java"
|
||||||
replace "mod_version", project.version.toString()
|
replace "@VERSION@", project.version.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|
|
@ -93,6 +93,11 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IAct
|
||||||
return new TileEntityAtomicReconstructor();
|
return new TileEntityAtomicReconstructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOpaqueCube(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
|
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack){
|
||||||
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
|
int rotation = BlockPistonBase.determineOrientation(world, x, y, z, player);
|
||||||
|
@ -111,7 +116,6 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IAct
|
||||||
ItemStack toPut = heldItem.copy();
|
ItemStack toPut = heldItem.copy();
|
||||||
toPut.stackSize = 1;
|
toPut.stackSize = 1;
|
||||||
reconstructor.setInventorySlotContents(0, toPut);
|
reconstructor.setInventorySlotContents(0, toPut);
|
||||||
|
|
||||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* This file ("RenderReconstructorLens.java") is part of the Actually Additions Mod for Minecraft.
|
||||||
|
* It is created and owned by Ellpeck and distributed
|
||||||
|
* under the Actually Additions License to be found at
|
||||||
|
* http://github.com/Ellpeck/ActuallyAdditions/blob/master/README.md
|
||||||
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||||
|
*
|
||||||
|
* © 2015 Ellpeck
|
||||||
|
*/
|
||||||
|
|
||||||
|
package ellpeck.actuallyadditions.blocks.render;
|
||||||
|
|
||||||
|
import ellpeck.actuallyadditions.items.IReconstructorLens;
|
||||||
|
import ellpeck.actuallyadditions.tile.TileEntityAtomicReconstructor;
|
||||||
|
import ellpeck.actuallyadditions.util.AssetUtil;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
public class RenderReconstructorLens extends TileEntitySpecialRenderer{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par5){
|
||||||
|
if(!(tile instanceof TileEntityAtomicReconstructor)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ItemStack stack = ((TileEntityAtomicReconstructor)tile).getStackInSlot(0);
|
||||||
|
|
||||||
|
if(stack != null && stack.getItem() instanceof IReconstructorLens){
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslatef((float)x+0.5F, (float)y-0.5F, (float)z+0.5F);
|
||||||
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
||||||
|
|
||||||
|
int meta = tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord);
|
||||||
|
if(meta == 0){
|
||||||
|
GL11.glTranslatef(0F, -0.5F, 0F);
|
||||||
|
GL11.glTranslatef(-0.25F, 0F, -0.25F);
|
||||||
|
GL11.glRotatef(90F, 1F, 0F, 0F);
|
||||||
|
}
|
||||||
|
if(meta == 1){
|
||||||
|
GL11.glTranslatef(0F, -1.5F-0.5F/16F, 0F);
|
||||||
|
GL11.glTranslatef(-0.25F, 0F, -0.25F);
|
||||||
|
GL11.glRotatef(90F, 1F, 0F, 0F);
|
||||||
|
}
|
||||||
|
if(meta == 2){
|
||||||
|
GL11.glTranslatef(0F, -1F, 0F);
|
||||||
|
GL11.glTranslatef(0F, 0F, -0.5F);
|
||||||
|
GL11.glTranslatef(-0.25F, -0.25F, 0F);
|
||||||
|
}
|
||||||
|
if(meta == 3){
|
||||||
|
GL11.glTranslatef(0F, -1F, 0F);
|
||||||
|
GL11.glTranslatef(0F, 0F, 0.5F+0.5F/16F);
|
||||||
|
GL11.glTranslatef(-0.25F, -0.25F, 0F);
|
||||||
|
}
|
||||||
|
if(meta == 4){
|
||||||
|
GL11.glTranslatef(0F, -1F, 0F);
|
||||||
|
GL11.glTranslatef(0.5F+0.5F/16F, 0F, 0F);
|
||||||
|
GL11.glTranslatef(0F, -0.25F, 0.25F);
|
||||||
|
GL11.glRotatef(90F, 0F, 1F, 0F);
|
||||||
|
}
|
||||||
|
if(meta == 5){
|
||||||
|
GL11.glTranslatef(0F, -1F, 0F);
|
||||||
|
GL11.glTranslatef(-0.5F, 0F, 0F);
|
||||||
|
GL11.glTranslatef(0F, -0.25F, 0.25F);
|
||||||
|
GL11.glRotatef(90F, 0F, 1F, 0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
||||||
|
AssetUtil.renderItem(stack, 0);
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,10 +17,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||||
import ellpeck.actuallyadditions.blocks.render.RenderInventory;
|
import ellpeck.actuallyadditions.blocks.render.*;
|
||||||
import ellpeck.actuallyadditions.blocks.render.RenderLaserRelay;
|
|
||||||
import ellpeck.actuallyadditions.blocks.render.RenderSmileyCloud;
|
|
||||||
import ellpeck.actuallyadditions.blocks.render.RenderTileEntity;
|
|
||||||
import ellpeck.actuallyadditions.blocks.render.model.*;
|
import ellpeck.actuallyadditions.blocks.render.model.*;
|
||||||
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
|
import ellpeck.actuallyadditions.config.values.ConfigBoolValues;
|
||||||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||||
|
@ -84,6 +81,7 @@ public class ClientProxy implements IProxy{
|
||||||
registerRenderer(TileEntitySmileyCloud.class, new RenderSmileyCloud(new ModelSmileyCloud()), AssetUtil.smileyCloudRenderId);
|
registerRenderer(TileEntitySmileyCloud.class, new RenderSmileyCloud(new ModelSmileyCloud()), AssetUtil.smileyCloudRenderId);
|
||||||
registerRenderer(TileEntityLaserRelay.class, new RenderLaserRelay(new ModelLaserRelay()), AssetUtil.laserRelayRenderId);
|
registerRenderer(TileEntityLaserRelay.class, new RenderLaserRelay(new ModelLaserRelay()), AssetUtil.laserRelayRenderId);
|
||||||
registerRenderer(TileEntityBookletStand.class, new RenderTileEntity(new ModelBookletStand()), AssetUtil.bookletStandRenderId);
|
registerRenderer(TileEntityBookletStand.class, new RenderTileEntity(new ModelBookletStand()), AssetUtil.bookletStandRenderId);
|
||||||
|
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAtomicReconstructor.class, new RenderReconstructorLens());
|
||||||
|
|
||||||
VillagerRegistry.instance().registerVillagerSkin(ConfigIntValues.JAM_VILLAGER_ID.getValue(), new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/entity/villager/jamVillager.png"));
|
VillagerRegistry.instance().registerVillagerSkin(ConfigIntValues.JAM_VILLAGER_ID.getValue(), new ResourceLocation(ModUtil.MOD_ID_LOWER, "textures/entity/villager/jamVillager.png"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,11 +209,33 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
||||||
return stack != null && stack.getItem() instanceof IReconstructorLens;
|
return this.isItemValidForSlot(slot, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isItemValidForSlot(int i, ItemStack stack){
|
||||||
|
return stack != null && stack.getItem() instanceof IReconstructorLens;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldSyncSlots(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack decrStackSize(int i, int j){
|
||||||
|
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||||
|
return super.decrStackSize(i, j);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setInventorySlotContents(int i, ItemStack stack){
|
||||||
|
super.setInventorySlotContents(i, stack);
|
||||||
|
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,18 +31,22 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
||||||
this.slots = new ItemStack[itemAmount];
|
this.slots = new ItemStack[itemAmount];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean shouldSyncSlots(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
public void writeSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||||
if(!isForSync){
|
if(!isForSync || this.shouldSyncSlots()){
|
||||||
if(this.slots.length > 0){
|
if(this.slots.length > 0){
|
||||||
NBTTagList tagList = new NBTTagList();
|
NBTTagList tagList = new NBTTagList();
|
||||||
for(int currentIndex = 0; currentIndex < slots.length; currentIndex++){
|
for(int currentIndex = 0; currentIndex < slots.length; currentIndex++){
|
||||||
if(slots[currentIndex] != null){
|
|
||||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||||
tagCompound.setByte("Slot", (byte)currentIndex);
|
tagCompound.setByte("Slot", (byte)currentIndex);
|
||||||
|
if(slots[currentIndex] != null){
|
||||||
slots[currentIndex].writeToNBT(tagCompound);
|
slots[currentIndex].writeToNBT(tagCompound);
|
||||||
tagList.appendTag(tagCompound);
|
|
||||||
}
|
}
|
||||||
|
tagList.appendTag(tagCompound);
|
||||||
}
|
}
|
||||||
compound.setTag("Items", tagList);
|
compound.setTag("Items", tagList);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +55,7 @@ public abstract class TileEntityInventoryBase extends TileEntityBase implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
public void readSyncableNBT(NBTTagCompound compound, boolean isForSync){
|
||||||
if(!isForSync){
|
if(!isForSync || this.shouldSyncSlots()){
|
||||||
if(this.slots.length > 0){
|
if(this.slots.length > 0){
|
||||||
NBTTagList tagList = compound.getTagList("Items", 10);
|
NBTTagList tagList = compound.getTagList("Items", 10);
|
||||||
for(int i = 0; i < tagList.tagCount(); i++){
|
for(int i = 0; i < tagList.tagCount(); i++){
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.apache.logging.log4j.Logger;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class ModUtil{
|
public class ModUtil{
|
||||||
public static final String VERSION = "mod_version"; // Will be replaced by gradle
|
public static final String VERSION = "@VERSION@"; //build.gradle
|
||||||
|
|
||||||
public static final String MOD_ID = "ActuallyAdditions";
|
public static final String MOD_ID = "ActuallyAdditions";
|
||||||
public static final String NAME = "Actually Additions";
|
public static final String NAME = "Actually Additions";
|
||||||
|
|
Loading…
Reference in a new issue