Browse Source

Adds nesting box crafted with 2 cut grass + 4 planks or plates

Qwertygiy 2 years ago
parent
commit
4c6eb68a91

+ 7
- 0
src/main/java/com/kbi/qwertech/QwerTech.java View File

@@ -700,6 +700,7 @@ public final class QwerTech extends Abstract_Mod {
700 700
                 //move these afterwards because they use the chest in the recipe
701 701
                 machines.add(woodType.mNameLocal + " Counterdrawers", "Counterdrawers", 980 + q, 0, CountertopShelvesTileEntity.class, 0, 16, wood, UT.NBT.make(NullBT, CS.NBT_MATERIAL, woodType, CS.NBT_INV_SIZE, 9 + 18, CS.NBT_TEXTURE, "qwertech:wood", CS.NBT_HARDNESS, 3.0F, CS.NBT_RESISTANCE, 3.0F, CS.NBT_COLOR, UT.Code.getRGBInt(woodType.fRGBaSolid)), "GCG", "PHP", 'C', machines.getItem(410 + q), 'P', "plank" + woodType.mNameInternal, 'H', machines.getItem(1510 + q), 'G', OD.itemGlue);
702 702
                 CR.shaped(machines.getItem(980 + q), new Object[]{"GCG", "PHP", 'C', machines.getItem(410 + q), 'P', "plank" + woodType.mNameInternal, 'H', machines.getItem(1510 + q), 'G', OD.slimeball});
703
+                machines.add(woodType.mNameLocal + " Nesting Box", "Nesting Boxes", 1780 + q, 0, NestBoxTileEntity.class, 0, 16, wood, UT.NBT.make(NullBT, CS.NBT_MATERIAL, woodType, CS.NBT_INV_SIZE, 5, CS.NBT_TEXTURE, "qwertech:wood", CS.NBT_HARDNESS, 3.0F, CS.NBT_RESISTANCE, 3.0F, CS.NBT_COLOR, UT.Code.getRGBInt(woodType.fRGBaSolid)), "GGP", "PPP", 'P', "plank" + woodType.mNameInternal, 'G', IL.Grass.get(1));
703 704
             }
704 705
         }
705 706
         machines.add("Wooden Chest", "Chests", 1510, 0, ChestTileEntity.class, 0, 64, wood, UT.NBT.make(NullBT, CS.NBT_MATERIAL, MT.Wood, CS.NBT_INV_SIZE, 27, CS.NBT_TEXTURE, "woodenchest", CS.NBT_HARDNESS, 3.0F, CS.NBT_RESISTANCE, 3.0F, CS.NBT_COLOR, UT.Code.getRGBInt(MT.Wood.fRGBaSolid)));
@@ -709,6 +710,12 @@ public final class QwerTech extends Abstract_Mod {
709 710
         GameRegistry.addRecipe(new WoodSpecificCrafting(machines.getItem(1510), "PPP", "P P", "PPP", 'P', "plankWood"));
710 711
 
711 712
         machines.add("Nest (ground)", "Natural", 1770, -1, NestTileEntity.class, 0, 1, wood, UT.NBT.make(NullBT, CS.NBT_INV_SIZE, 5, CS.NBT_HARDNESS, 1.0F, CS.NBT_RESISTANCE, 1.0F));
713
+        OreDictMaterial[] nestBoxMats = new OreDictMaterial[]{MT.Plastic, MT.Steel, MT.Bronze, MT.Brass, MT.Cu, MT.Ag, MT.Au, MT.Invar, MT.Electrum, MT.Concrete, MT.Asphalt, MT.Al, MT.Ti, MT.StainlessSteel, MT.SteelGalvanized, MT.Pt, MT.Ceramic};
714
+        for (int q = 0; q < nestBoxMats.length; q++)
715
+        {
716
+            OreDictMaterial mat = nestBoxMats[q];
717
+            machines.add(mat.mNameLocal + " Nesting Box", "Nesting Boxes", 2040 + q, 0, NestBoxTileEntity.class, 0, 16, metal, UT.NBT.make(NullBT, CS.NBT_MATERIAL, mat, CS.NBT_INV_SIZE, 5, CS.NBT_HARDNESS, 3.0F, CS.NBT_RESISTANCE, 3.0F, CS.NBT_COLOR, UT.Code.getRGBInt(mat.fRGBaSolid)), "GGP", "PPP", 'P', "plate" + mat.mNameInternal, 'G', IL.Grass.get(1));
718
+        }
712 719
     }
713 720
 
714 721
 	@Override

+ 162
- 0
src/main/java/com/kbi/qwertech/tileentities/NestBoxTileEntity.java View File

@@ -0,0 +1,162 @@
1
+package com.kbi.qwertech.tileentities;
2
+
3
+import gregapi.block.multitileentity.IMultiTileEntity;
4
+import gregapi.block.multitileentity.MultiTileEntityBlockInternal;
5
+import gregapi.data.MT;
6
+import gregapi.data.OP;
7
+import gregapi.old.Textures;
8
+import gregapi.oredict.OreDictMaterial;
9
+import gregapi.render.BlockTextureDefault;
10
+import gregapi.render.IIconContainer;
11
+import gregapi.render.ITexture;
12
+import gregapi.util.UT;
13
+import net.minecraft.block.Block;
14
+import net.minecraft.creativetab.CreativeTabs;
15
+import net.minecraft.entity.Entity;
16
+import net.minecraft.item.Item;
17
+import net.minecraft.item.ItemStack;
18
+import net.minecraft.nbt.NBTTagCompound;
19
+import net.minecraft.util.AxisAlignedBB;
20
+
21
+import java.awt.*;
22
+import java.util.List;
23
+
24
+import static gregapi.data.CS.*;
25
+
26
+public class NestBoxTileEntity extends NestTileEntity implements IMultiTileEntity.IMTE_GetSubItems {
27
+
28
+    protected OreDictMaterial mMaterial = MT.NULL;
29
+
30
+    @Override
31
+    public String getTileEntityName() {
32
+        return super.getTileEntityName() + ".manmade";
33
+    }
34
+
35
+    @Override
36
+    public boolean getSubItems(MultiTileEntityBlockInternal aBlock, Item aItem,
37
+                               CreativeTabs aTab, List aList, short aID) {
38
+        return SHOW_HIDDEN_MATERIALS || !mMaterial.mHidden;
39
+    }
40
+
41
+    @Override
42
+    public void readFromNBT2(NBTTagCompound aNBT) {
43
+        super.readFromNBT2(aNBT);
44
+        if (aNBT.hasKey(NBT_MATERIAL)) mMaterial = OreDictMaterial.get(aNBT.getString(NBT_MATERIAL));
45
+    }
46
+
47
+    public static IIconContainer wood = new Textures.BlockIcons.CustomIcon("qwertech:nestbox/wood");
48
+    @Override
49
+    public ITexture getTexture(Block aBlock, int aRenderPass, byte aSide, boolean[] aShouldSideBeRendered) {
50
+        if (aRenderPass > 9)
51
+        {
52
+            ItemStack stack = slot(aRenderPass - 10);
53
+            short[] colors = new short[4];
54
+            if (stack != null)
55
+            {
56
+                NBTTagCompound nbt = UT.NBT.getOrCreate(stack);
57
+                int color = nbt.getInteger("itemColor");
58
+                Color oColor = Color.getColor(null, color);
59
+                colors[0] = (short)oColor.getRed();
60
+                colors[1] = (short)oColor.getBlue();
61
+                colors[2] = (short)oColor.getGreen();
62
+                colors[3] = (short)oColor.getAlpha();
63
+                return BlockTextureDefault.get(MT.Bone.mTextureSetsBlock.get(OP.blockDust.mIconIndexBlock), colors);
64
+                //return BlockTextureDefault.get(nest, colors);
65
+            }
66
+            return null;
67
+        } else if (aRenderPass < 5) {
68
+            if (ourcolor == null) {
69
+                ourcolor = new short[]{(short) (210 + Math.abs(this.xCoord % 16)), (short) (245 + Math.abs(this.zCoord % 8)), (short) (200 + Math.abs(this.zCoord % 16) - Math.abs(this.xCoord % 12)), 255};
70
+            }
71
+            return BlockTextureDefault.get(nest, ourcolor);
72
+        } else {
73
+            return BlockTextureDefault.get(wood, this.mMaterial.fRGBaSolid);
74
+        }
75
+    }
76
+
77
+    @Override
78
+    public AxisAlignedBB getSelectedBoundingBoxFromPool() {
79
+        return this.box(PX_P[0], PX_P[0], PX_P[0], PX_P[16], PX_P[7], PX_P[16]);
80
+    }
81
+
82
+    @Override
83
+    public AxisAlignedBB getCollisionBoundingBoxFromPool() {
84
+        return this.box(0, 0, 0, 1, 0.5, 1);
85
+    }
86
+
87
+    @Override
88
+    public void setBlockBoundsBasedOnState(Block aBlock) {
89
+        aBlock.setBlockBounds(PX_P[0], PX_P[0], PX_P[0], PX_P[16], PX_P[7], PX_P[16]);
90
+    }
91
+
92
+    @Override
93
+    public void addCollisionBoxesToList(AxisAlignedBB aAABB, List<AxisAlignedBB> aList, Entity aEntity) {
94
+        this.box(aAABB, aList, PX_P[0], PX_P[0], PX_P[0], PX_P[16], PX_P[3], PX_P[16]);
95
+        this.box(aAABB, aList, PX_P[0], PX_P[0], PX_P[0], PX_P[16], PX_P[7], PX_P[1]);
96
+        this.box(aAABB, aList, PX_P[0], PX_P[0], PX_P[15], PX_P[16], PX_P[7], PX_P[16]);
97
+        this.box(aAABB, aList, PX_P[0], PX_P[0], PX_P[0], PX_P[1], PX_P[7], PX_P[16]);
98
+        this.box(aAABB, aList, PX_P[15], PX_P[0], PX_P[0], PX_P[16], PX_P[7], PX_P[16]);
99
+    }
100
+
101
+    @Override
102
+    public int getRenderPasses(Block aBlock, boolean[] aShouldSideBeRendered) {
103
+        return super.getRenderPasses(aBlock, aShouldSideBeRendered) + 5;
104
+    }
105
+
106
+    @Override
107
+    public boolean setBlockBounds(Block aBlock, int aRenderPass, boolean[] aShouldSideBeRendered) {
108
+        switch(aRenderPass) {
109
+            case 14:
110
+                //egg
111
+                aBlock.setBlockBounds(PX_P[7], PX_P[2], PX_P[9], PX_P[10], PX_P[6], PX_P[12]);
112
+                break;
113
+            case 13:
114
+                //egg
115
+                aBlock.setBlockBounds(PX_P[9], PX_P[2], PX_P[5], PX_P[12], PX_P[6], PX_P[8]);
116
+                break;
117
+            case 12:
118
+                //egg
119
+                aBlock.setBlockBounds(PX_P[5], PX_P[2], PX_P[7], PX_P[8], PX_P[6], PX_P[11]);
120
+                break;
121
+            case 11:
122
+                //egg
123
+                aBlock.setBlockBounds(PX_P[5], PX_P[2], PX_P[6], PX_P[8], PX_P[6], PX_P[9]);
124
+                break;
125
+            case 10:
126
+                //egg
127
+                aBlock.setBlockBounds(PX_P[7], PX_P[2], PX_P[7], PX_P[10], PX_P[6], PX_P[10]);
128
+                break;
129
+            case 9:
130
+                aBlock.setBlockBounds(PX_P[2], PX_P[0], PX_P[14], PX_P[14], PX_P[7], PX_P[16]);
131
+                break;
132
+            case 8:
133
+                aBlock.setBlockBounds(PX_P[2], PX_P[0], PX_P[0], PX_P[14], PX_P[7], PX_P[2]);
134
+                break;
135
+            case 7:
136
+                aBlock.setBlockBounds(PX_P[14], PX_P[0], PX_P[0], PX_P[16], PX_P[7], PX_P[16]);
137
+                break;
138
+            case 6:
139
+                aBlock.setBlockBounds(PX_P[0], PX_P[0], PX_P[0], PX_P[2], PX_P[7], PX_P[16]);
140
+                break;
141
+            case 5:
142
+                aBlock.setBlockBounds(PX_P[1], PX_P[0], PX_P[1], PX_P[15], PX_P[1], PX_P[15]);
143
+                break;
144
+            case 4:
145
+                aBlock.setBlockBounds(PX_P[1], PX_P[2], PX_P[13], PX_P[15], PX_P[4], PX_P[15]);
146
+                break;
147
+            case 3:
148
+                aBlock.setBlockBounds(PX_P[1], PX_P[2], PX_P[1], PX_P[15], PX_P[4], PX_P[3]);
149
+                break;
150
+            case 2:
151
+                aBlock.setBlockBounds(PX_P[13], PX_P[2], PX_P[1], PX_P[15], PX_P[4], PX_P[15]);
152
+                break;
153
+            case 1:
154
+                aBlock.setBlockBounds(PX_P[1], PX_P[2], PX_P[1], PX_P[3], PX_P[4], PX_P[15]);
155
+                break;
156
+            case 0:
157
+                aBlock.setBlockBounds(PX_P[1], PX_P[1], PX_P[1], PX_P[15], PX_P[2], PX_P[15]);
158
+        }
159
+        return true;
160
+    }
161
+
162
+}

+ 2
- 2
src/main/java/com/kbi/qwertech/tileentities/NestTileEntity.java View File

@@ -42,6 +42,7 @@ public class NestTileEntity extends TileEntityBase05Inventories implements IMult
42 42
     @Override
43 43
     public void onTick(long aTimer, boolean aIsServerSide) {
44 44
         super.onTick(aTimer, aIsServerSide);
45
+        if (!hasWorldObj()) return;
45 46
         if (aIsServerSide) {
46 47
             if (mUpdatedGrid) {
47 48
                 sendDisplays();
@@ -115,7 +116,7 @@ public class NestTileEntity extends TileEntityBase05Inventories implements IMult
115 116
     public void readFromNBT2(NBTTagCompound aNBT) {
116 117
         super.readFromNBT2(aNBT);
117 118
         String entityID = aNBT.getString("ENT");
118
-        if (entityID != null && entityID.length() > 0)
119
+        if (worldObj != null && entityID != null && entityID.length() > 0)
119 120
         {
120 121
             UUID uuid = UUID.fromString(entityID);
121 122
             if (chosenEntity == null || chosenEntity.getUniqueID() != uuid)
@@ -132,7 +133,6 @@ public class NestTileEntity extends TileEntityBase05Inventories implements IMult
132 133
                 }
133 134
             }
134 135
         }
135
-        sendDisplays();
136 136
     }
137 137
 
138 138
     @Override

BIN
src/main/resources/assets/qwertech/textures/blocks/nestbox/wood.png View File


Loading…
Cancel
Save