Move to RenderType from BlockRenderLayer, isSneaking -> isCrouching

This commit is contained in:
raoulvdberge
2019-12-19 22:13:53 +01:00
parent 5e0cb07876
commit 1a2052adaa
25 changed files with 42 additions and 78 deletions

View File

@@ -8,6 +8,7 @@ import com.raoulvdberge.refinedstorage.api.network.item.INetworkItemProvider;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode; import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.util.text.TranslationTextComponent;
import java.util.Map; import java.util.Map;
@@ -31,7 +32,9 @@ public class NetworkItemManager implements INetworkItemManager {
((IWirelessTransmitter) node).getDimension() == player.dimension) { ((IWirelessTransmitter) node).getDimension() == player.dimension) {
IWirelessTransmitter transmitter = (IWirelessTransmitter) node; IWirelessTransmitter transmitter = (IWirelessTransmitter) node;
double distance = Math.sqrt(Math.pow(transmitter.getOrigin().getX() - player.posX, 2) + Math.pow(transmitter.getOrigin().getY() - player.posY, 2) + Math.pow(transmitter.getOrigin().getZ() - player.posZ, 2)); Vec3d pos = player.getPositionVec();
double distance = Math.sqrt(Math.pow(transmitter.getOrigin().getX() - pos.getX(), 2) + Math.pow(transmitter.getOrigin().getY() - pos.getY(), 2) + Math.pow(transmitter.getOrigin().getZ() - pos.getZ(), 2));
if (distance < transmitter.getRange()) { if (distance < transmitter.getRange()) {
inRange = true; inRange = true;

View File

@@ -126,7 +126,7 @@ public class StorageMonitorNetworkNode extends NetworkNode implements IComparabl
ItemStack filter = itemFilter.getStackInSlot(0); ItemStack filter = itemFilter.getStackInSlot(0);
int toExtract = player.isSneaking() ? 1 : 64; int toExtract = player.isCrouching() ? 1 : 64;
if (!filter.isEmpty()) { if (!filter.isEmpty()) {
ItemStack result = network.extractItem(filter, toExtract, compare, Action.PERFORM); ItemStack result = network.extractItem(filter, toExtract, compare, Action.PERFORM);

View File

@@ -82,6 +82,8 @@ public class ConstructorBlock extends CableBlock {
return shape; return shape;
} }
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {

View File

@@ -18,7 +18,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.state.EnumProperty; import net.minecraft.state.EnumProperty;
import net.minecraft.state.StateContainer; import net.minecraft.state.StateContainer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.IStringSerializable; import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -79,11 +78,6 @@ public class ControllerBlock extends BaseBlock {
return type; return type;
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override @Override
public boolean hasTileEntity(BlockState state) { public boolean hasTileEntity(BlockState state) {
return true; return true;

View File

@@ -30,11 +30,6 @@ public class CrafterBlock extends NetworkNodeBlock {
this.setRegistryName(RS.ID, "crafter"); this.setRegistryName(RS.ID, "crafter");
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override @Override
public BlockDirection getDirection() { public BlockDirection getDirection() {
return BlockDirection.ANY_FACE_PLAYER; return BlockDirection.ANY_FACE_PLAYER;

View File

@@ -27,11 +27,6 @@ public class CrafterManagerBlock extends NetworkNodeBlock {
this.setRegistryName(RS.ID, "crafter_manager"); this.setRegistryName(RS.ID, "crafter_manager");
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override @Override
public BlockDirection getDirection() { public BlockDirection getDirection() {
return BlockDirection.HORIZONTAL; return BlockDirection.HORIZONTAL;

View File

@@ -28,11 +28,6 @@ public class CraftingMonitorBlock extends NetworkNodeBlock {
this.setRegistryName(RS.ID, "crafting_monitor"); this.setRegistryName(RS.ID, "crafting_monitor");
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override @Override
public BlockDirection getDirection() { public BlockDirection getDirection() {
return BlockDirection.HORIZONTAL; return BlockDirection.HORIZONTAL;

View File

@@ -52,12 +52,6 @@ public class DetectorBlock extends NetworkNodeBlock {
return SHAPE; return SHAPE;
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public boolean canProvidePower(BlockState state) { public boolean canProvidePower(BlockState state) {

View File

@@ -28,11 +28,6 @@ public class DiskManipulatorBlock extends NetworkNodeBlock {
this.setRegistryName(RS.ID, "disk_manipulator"); this.setRegistryName(RS.ID, "disk_manipulator");
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@Nullable @Nullable
@Override @Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) { public TileEntity createTileEntity(BlockState state, IBlockReader world) {

View File

@@ -31,11 +31,6 @@ public class GridBlock extends NetworkNodeBlock {
this.setRegistryName(RS.ID, type == GridType.NORMAL ? "grid" : type.getName() + "_grid"); this.setRegistryName(RS.ID, type == GridType.NORMAL ? "grid" : type.getName() + "_grid");
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override @Override
public BlockDirection getDirection() { public BlockDirection getDirection() {
return BlockDirection.HORIZONTAL; return BlockDirection.HORIZONTAL;

View File

@@ -23,11 +23,6 @@ public class NetworkReceiverBlock extends NetworkNodeBlock {
return new NetworkReceiverTile(); return new NetworkReceiverTile();
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override @Override
public boolean hasConnectedState() { public boolean hasConnectedState() {
return true; return true;

View File

@@ -28,11 +28,6 @@ public class NetworkTransmitterBlock extends NetworkNodeBlock {
this.setRegistryName(RS.ID, "network_transmitter"); this.setRegistryName(RS.ID, "network_transmitter");
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@Nullable @Nullable
@Override @Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) { public TileEntity createTileEntity(BlockState state, IBlockReader world) {

View File

@@ -28,11 +28,6 @@ public class RelayBlock extends NetworkNodeBlock {
this.setRegistryName(RS.ID, "relay"); this.setRegistryName(RS.ID, "relay");
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@Nullable @Nullable
@Override @Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) { public TileEntity createTileEntity(BlockState state, IBlockReader world) {

View File

@@ -29,11 +29,6 @@ public class SecurityManagerBlock extends NetworkNodeBlock {
this.setRegistryName(RS.ID, "security_manager"); this.setRegistryName(RS.ID, "security_manager");
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override @Override
public BlockDirection getDirection() { public BlockDirection getDirection() {
return BlockDirection.HORIZONTAL; return BlockDirection.HORIZONTAL;

View File

@@ -48,7 +48,7 @@ public class StorageMonitorBlock extends NetworkNodeBlock {
if (!world.isRemote) { if (!world.isRemote) {
ItemStack held = player.inventory.getCurrentItem(); ItemStack held = player.inventory.getCurrentItem();
if (player.isSneaking()) { if (player.isCrouching()) {
return NetworkUtils.attemptModify(world, pos, hit.getFace(), player, () -> NetworkHooks.openGui( return NetworkUtils.attemptModify(world, pos, hit.getFace(), player, () -> NetworkHooks.openGui(
(ServerPlayerEntity) player, (ServerPlayerEntity) player,
new PositionalTileContainerProvider<StorageMonitorTile>( new PositionalTileContainerProvider<StorageMonitorTile>(

View File

@@ -49,11 +49,6 @@ public class WirelessTransmitterBlock extends NetworkNodeBlock {
return SHAPE; return SHAPE;
} }
@Override
public BlockRenderLayer getRenderLayer() {
return BlockRenderLayer.CUTOUT;
}
@Override @Override
public boolean hasConnectedState() { public boolean hasConnectedState() {
return true; return true;
@@ -71,6 +66,8 @@ public class WirelessTransmitterBlock extends NetworkNodeBlock {
return facing == Direction.DOWN && !this.isValidPosition(state, world, currentPos) ? Blocks.AIR.getDefaultState() : super.updatePostPlacement(state, facing, facingState, world, currentPos, facingPos); return facing == Direction.DOWN && !this.isValidPosition(state, world, currentPos) ? Blocks.AIR.getDefaultState() : super.updatePostPlacement(state, facing, facingState, world, currentPos, facingPos);
} }
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { public boolean onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {

View File

@@ -51,7 +51,7 @@ public class FilterItem extends Item {
ItemStack stack = player.getHeldItem(hand); ItemStack stack = player.getHeldItem(hand);
if (!world.isRemote) { if (!world.isRemote) {
if (player.isSneaking()) { if (player.isCrouching()) {
return new ActionResult<>(ActionResultType.SUCCESS, new ItemStack(RSItems.FILTER)); return new ActionResult<>(ActionResultType.SUCCESS, new ItemStack(RSItems.FILTER));
} }

View File

@@ -84,7 +84,7 @@ public class FluidStorageDiskItem extends Item implements IStorageDiskProvider {
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) { public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
ItemStack diskStack = player.getHeldItem(hand); ItemStack diskStack = player.getHeldItem(hand);
if (!world.isRemote && player.isSneaking() && type != FluidStorageType.CREATIVE) { if (!world.isRemote && player.isCrouching() && type != FluidStorageType.CREATIVE) {
IStorageDisk disk = API.instance().getStorageDiskManager((ServerWorld) world).getByStack(diskStack); IStorageDisk disk = API.instance().getStorageDiskManager((ServerWorld) world).getByStack(diskStack);
if (disk != null && disk.getStored() == 0) { if (disk != null && disk.getStored() == 0) {

View File

@@ -126,7 +126,7 @@ public class PatternItem extends Item implements ICraftingPatternProvider {
@Override @Override
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) { public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
if (!world.isRemote && player.isSneaking()) { if (!world.isRemote && player.isCrouching()) {
return new ActionResult<>(ActionResultType.SUCCESS, new ItemStack(RSItems.PATTERN, player.getHeldItem(hand).getCount())); return new ActionResult<>(ActionResultType.SUCCESS, new ItemStack(RSItems.PATTERN, player.getHeldItem(hand).getCount()));
} }

View File

@@ -84,7 +84,7 @@ public class StorageDiskItem extends Item implements IStorageDiskProvider {
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) { public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
ItemStack diskStack = player.getHeldItem(hand); ItemStack diskStack = player.getHeldItem(hand);
if (!world.isRemote && player.isSneaking() && type != ItemStorageType.CREATIVE) { if (!world.isRemote && player.isCrouching() && type != ItemStorageType.CREATIVE) {
IStorageDisk disk = API.instance().getStorageDiskManager((ServerWorld) world).getByStack(diskStack); IStorageDisk disk = API.instance().getStorageDiskManager((ServerWorld) world).getByStack(diskStack);
if (disk != null && disk.getStored() == 0) { if (disk != null && disk.getStored() == 0) {

View File

@@ -20,7 +20,7 @@ public class WrenchItem extends Item {
@Override @Override
public ActionResultType onItemUse(ItemUseContext ctx) { public ActionResultType onItemUse(ItemUseContext ctx) {
if (!ctx.getPlayer().isSneaking()) { if (!ctx.getPlayer().isCrouching()) {
return ActionResultType.FAIL; return ActionResultType.FAIL;
} }

View File

@@ -69,7 +69,7 @@ public class FluidStorageBlockItem extends BaseBlockItem {
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) { public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
ItemStack storageStack = player.getHeldItem(hand); ItemStack storageStack = player.getHeldItem(hand);
if (!world.isRemote && player.isSneaking() && type != FluidStorageType.CREATIVE) { if (!world.isRemote && player.isCrouching() && type != FluidStorageType.CREATIVE) {
UUID diskId = null; UUID diskId = null;
IStorageDisk disk = null; IStorageDisk disk = null;

View File

@@ -66,7 +66,7 @@ public class PortableGridBlockItem extends EnergyBlockItem {
@Override @Override
public ActionResultType onItemUse(ItemUseContext context) { public ActionResultType onItemUse(ItemUseContext context) {
if (!context.getPlayer().isSneaking()) { if (!context.getPlayer().isCrouching()) {
return ActionResultType.FAIL; return ActionResultType.FAIL;
} }

View File

@@ -68,7 +68,7 @@ public class StorageBlockItem extends BaseBlockItem {
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) { public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
ItemStack storageStack = player.getHeldItem(hand); ItemStack storageStack = player.getHeldItem(hand);
if (!world.isRemote && player.isSneaking() && type != ItemStorageType.CREATIVE) { if (!world.isRemote && player.isCrouching() && type != ItemStorageType.CREATIVE) {
UUID diskId = null; UUID diskId = null;
IStorageDisk disk = null; IStorageDisk disk = null;

View File

@@ -1,9 +1,6 @@
package com.raoulvdberge.refinedstorage.setup; package com.raoulvdberge.refinedstorage.setup;
import com.raoulvdberge.refinedstorage.RS; import com.raoulvdberge.refinedstorage.*;
import com.raoulvdberge.refinedstorage.RSContainers;
import com.raoulvdberge.refinedstorage.RSItems;
import com.raoulvdberge.refinedstorage.RSKeyBindings;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
import com.raoulvdberge.refinedstorage.container.CrafterContainer; import com.raoulvdberge.refinedstorage.container.CrafterContainer;
import com.raoulvdberge.refinedstorage.container.CrafterManagerContainer; import com.raoulvdberge.refinedstorage.container.CrafterManagerContainer;
@@ -20,6 +17,8 @@ import com.raoulvdberge.refinedstorage.tile.StorageMonitorTile;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScreenManager; import net.minecraft.client.gui.ScreenManager;
import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.Slot; import net.minecraft.inventory.container.Slot;
import net.minecraft.resources.IReloadableResourceManager; import net.minecraft.resources.IReloadableResourceManager;
@@ -209,7 +208,27 @@ public class ClientSetup {
ClientRegistry.registerKeyBinding(RSKeyBindings.OPEN_WIRELESS_CRAFTING_MONITOR); ClientRegistry.registerKeyBinding(RSKeyBindings.OPEN_WIRELESS_CRAFTING_MONITOR);
ClientRegistry.registerKeyBinding(RSKeyBindings.OPEN_PORTABLE_GRID); ClientRegistry.registerKeyBinding(RSKeyBindings.OPEN_PORTABLE_GRID);
ClientRegistry.bindTileEntitySpecialRenderer(StorageMonitorTile.class, new StorageMonitorTileRenderer()); RenderType cutout = RenderType.func_228643_e_();
RenderTypeLookup.setRenderLayer(RSBlocks.CONTROLLER, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.CREATIVE_CONTROLLER, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.CABLE, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.CRAFTER, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.CRAFTER_MANAGER, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.CRAFTING_MONITOR, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.DETECTOR, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.DISK_MANIPULATOR, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.GRID, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.CRAFTING_GRID, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.PATTERN_GRID, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.FLUID_GRID, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.NETWORK_RECEIVER, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.NETWORK_TRANSMITTER, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.RELAY, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.SECURITY_MANAGER, cutout);
RenderTypeLookup.setRenderLayer(RSBlocks.WIRELESS_TRANSMITTER, cutout);
// TODO ClientRegistry.bindTileEntitySpecialRenderer(StorageMonitorTile.class, new StorageMonitorTileRenderer());
e.getMinecraftSupplier().get().getItemColors().register(new PatternItemColor(), RSItems.PATTERN); e.getMinecraftSupplier().get().getItemColors().register(new PatternItemColor(), RSItems.PATTERN);
} }