Commits

Anonymous committed 6c18d24

applied missing data value copy to block duplicator also

Comments (0)

Files changed (1)

src/info/daybreaker/minecraft/PhilosophersCircuitListener.java

 		final World world = piston.getWorld();
 		final Location pistonLocation = piston.getLocation();
 		final Location retractedLocation = ev.getRetractLocation();
-		final Material sourceType = retractedLocation.getBlock().getType();
 
 		Block up1 = piston.getRelative(BlockFace.UP, 1);
 		Block up2 = piston.getRelative(BlockFace.UP, 2);
 
 		if (up1.getType().equals(Material.GLOWSTONE) && up2.getType().equals(Material.OBSIDIAN)) {
-
-			if (sourceType.equals(Material.CHEST)) {
+			final Material sourceType = retractedLocation.getBlock().getType();
+			
+			if (retractedLocation.getBlock().getType().equals(Material.CHEST)) {
 				// Copy the first item in the chest and decrement the amount of the original stack in the chest.
 				// If we do not decrement it, an infinite amount of item entities on the map may cause severe lag.
 				Chest chest = (Chest) retractedLocation.getBlock().getState();
 				if (stack != null) {
 					int amount = stack.getAmount();
 					if (amount > 0) {
-						Material m = stack.getType();
-						MaterialData data = stack.getData();
-						short dur = stack.getDurability();
-						ItemStack poppedStack = new ItemStack(m);
-						if (data != null)
-							poppedStack.setData(data);
-						poppedStack.setDurability(dur);
+						Material sourceMaterial = stack.getType();
+						MaterialData sourceData = stack.getData();
+						short sourceDurability = stack.getDurability();
+						ItemStack poppedStack = new ItemStack(sourceMaterial);
+						if (sourceData != null)
+							poppedStack.setData(sourceData);
+						poppedStack.setDurability(sourceDurability);
 						int numObsidiansAbove = 1;
 						for (int i = 3; i < 128 - pistonLocation.getBlockY(); i++) {
 							if (piston.getRelative(BlockFace.UP, i).getType().equals(Material.OBSIDIAN)) {
 					}
 				}
 			} else {
+				final byte sourceData = retractedLocation.getBlock().getData();
+				
 				if (!isDuplicable(retractedLocation.getBlock()))
 					return;
 				if (sourceType.equals(Material.PISTON_MOVING_PIECE)) // to avoid buggy situation
 						int t = world.getBlockTypeIdAt(retractedLocation);
 						if (t == Material.AIR.getId() || t == Material.PISTON_MOVING_PIECE.getId()) {
 							world.getBlockAt(retractedLocation).setType(sourceType);
+							world.getBlockAt(retractedLocation).setData(sourceData);
 						}
 					}
 				}, 2);