Skip to content

Commit 1cf4622

Browse files
committed
Added ability to lock machines and configure a whitelist for them
Also included are a few smaller fixes and improvements: - Added a proper GUI for the machine view - Fixed more MipMap flickering issues when viewing machine contents Fixes #228
1 parent 316ad3d commit 1cf4622

15 files changed

+664
-36
lines changed

src/main/java/org/dave/compactmachines3/block/BlockMachine.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, Entity
283283
tileEntityMachine.setCustomName(stack.getDisplayName());
284284
}
285285

286-
if(stack.getTagCompound().hasKey("owner")) {
286+
if(stack.getTagCompound().hasKey("ownerLeast") && stack.getTagCompound().hasKey("ownerMost")) {
287287
tileEntityMachine.setOwner(stack.getTagCompound().getUniqueId("owner"));
288288
}
289289
}
@@ -317,7 +317,7 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En
317317
}
318318

319319
ItemStack playerStack = player.getHeldItemMainhand();
320-
if(!playerStack.isEmpty()) {
320+
if(!playerStack.isEmpty() && machine.isAllowedToEnter(player)) {
321321
Item playerItem = playerStack.getItem();
322322

323323
// TODO: Convert the ability to teleport into a machine into an itemstack capability
@@ -340,6 +340,11 @@ public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, En
340340
TeleportationTools.teleportPlayerToMachine((EntityPlayerMP) player, machine);
341341
StructureTools.setBiomeForCoords(machine.coords, world.getBiome(pos));
342342

343+
if(!machine.hasOwner() || "Unknown".equals(machine.getOwnerName())) {
344+
machine.setOwner(player);
345+
machine.markDirty();
346+
}
347+
343348
return true;
344349
}
345350
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package org.dave.compactmachines3.gui;
2+
3+
import net.minecraft.client.renderer.BufferBuilder;
4+
import net.minecraft.client.renderer.Tessellator;
5+
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
6+
7+
public class GUIHelper {
8+
public static void drawStretchedTexture(int x, int y, int width, int height, int textureX, int textureY, int textureWidth, int textureHeight) {
9+
float f = 0.00390625F;
10+
double zLevel = 0.0f;
11+
12+
Tessellator tessellator = Tessellator.getInstance();
13+
BufferBuilder bufferbuilder = tessellator.getBuffer();
14+
bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
15+
bufferbuilder
16+
.pos((double)(x + 0), (double)(y + height), zLevel)
17+
.tex((double)((float)(textureX + 0) * f), (double)((float)(textureY + textureHeight) * f))
18+
.endVertex();
19+
20+
bufferbuilder
21+
.pos((double)(x + width), (double)(y + height), zLevel)
22+
.tex((double)((float)(textureX + textureWidth) * f), (double)((float)(textureY + textureHeight) * f))
23+
.endVertex();
24+
25+
bufferbuilder
26+
.pos((double)(x + width), (double)(y + 0), zLevel)
27+
.tex((double)((float)(textureX + textureWidth) * f), (double)((float)(textureY + 0) * f))
28+
.endVertex();
29+
30+
bufferbuilder
31+
.pos((double)(x + 0), (double)(y + 0), zLevel)
32+
.tex((double)((float)(textureX + 0) * f), (double)((float)(textureY + 0) * f))
33+
.endVertex();
34+
35+
tessellator.draw();
36+
}
37+
}

0 commit comments

Comments
 (0)