mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-04 03:16:43 +01:00
068b7c0c37
- Chassis blocks now visualize their range blocks when selected with a wrench - Fixed Bearings and other actors selecting moved blocks as if they were being pushed in a direction - Fixed Radial chassis not connecting to each other consistently - Added Powered Latch and Powered Toggle Latch (Redstone circuits) - Window-logging now works with modded glass panes, that do not have the tag on their item, but the block only - Chassis can now be edited in bulk by holding down Ctrl - Chained block movement no longer marks blocks for movement if they are in front of a block breaker - Making a chassis sticky no longer uses up slime balls - Chassis can now be made sticky on all sides if a sticky side is clicked once again - Fixed linear chassis picking up blocks attached to other chassis' lines, even if not sticky - Fixed horizontal rotation and mirroring of chassis blocks and their sticky sides - Structures rotated in a Contraption now try to rotate themselves and their blocks toward the nearest axis-alinged direction when disassembled - Fans no longer shoot testing rays if the target block shape is completely filled or empty (trivial case) - Fans can now blow through iron bars again - Fixed crash when adjusting motors - Fixed missing icons in blockzapper & schematicannon interface - Reworked the drill model - Added more tags to #windowable - Leather horse armor no longer crushes into iron nuggets
116 lines
3.7 KiB
Java
116 lines
3.7 KiB
Java
package com.simibubi.create;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import com.simibubi.create.config.AllConfigs;
|
|
import com.simibubi.create.modules.curiosities.partialWindows.WindowInABlockTileEntity;
|
|
|
|
import net.minecraft.block.BlockState;
|
|
import net.minecraft.block.FourWayBlock;
|
|
import net.minecraft.block.WallBlock;
|
|
import net.minecraft.item.BlockItem;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.state.BooleanProperty;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.util.math.BlockPos;
|
|
import net.minecraft.world.IWorld;
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.common.Tags;
|
|
import net.minecraftforge.event.TickEvent.Phase;
|
|
import net.minecraftforge.event.TickEvent.ServerTickEvent;
|
|
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock;
|
|
import net.minecraftforge.event.world.WorldEvent;
|
|
import net.minecraftforge.eventbus.api.Event.Result;
|
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
|
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
|
|
|
|
@EventBusSubscriber
|
|
public class Events {
|
|
|
|
@SubscribeEvent
|
|
public static void onTick(ServerTickEvent event) {
|
|
if (event.phase == Phase.END)
|
|
return;
|
|
|
|
Create.tick();
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void onClose(FMLServerStoppingEvent event) {
|
|
Create.shutdown();
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void onLoadWorld(WorldEvent.Load event) {
|
|
IWorld world = event.getWorld();
|
|
Create.redstoneLinkNetworkHandler.onLoadWorld(world);
|
|
Create.torquePropagator.onLoadWorld(world);
|
|
// Create.logisticalNetworkHandler.onLoadWorld(world);
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void onUnloadWorld(WorldEvent.Unload event) {
|
|
IWorld world = event.getWorld();
|
|
Create.redstoneLinkNetworkHandler.onUnloadWorld(world);
|
|
Create.torquePropagator.onUnloadWorld(world);
|
|
// Create.logisticalNetworkHandler.onUnloadWorld(world);
|
|
}
|
|
|
|
@SubscribeEvent
|
|
public static void onRightClickBlock(RightClickBlock event) {
|
|
if (event.getUseItem() == Result.DENY)
|
|
return;
|
|
if (event.getEntityLiving().isSneaking())
|
|
return;
|
|
if (!event.getPlayer().isAllowEdit())
|
|
return;
|
|
if (!AllConfigs.SERVER.curiosities.allowGlassPanesInPartialBlocks.get())
|
|
return;
|
|
|
|
ItemStack stack = event.getItemStack();
|
|
if (stack.isEmpty())
|
|
return;
|
|
if (!(stack.getItem() instanceof BlockItem))
|
|
return;
|
|
BlockItem item = (BlockItem) stack.getItem();
|
|
if (!item.isIn(Tags.Items.GLASS_PANES)
|
|
&& (item.getBlock() == null || !item.getBlock().isIn(Tags.Blocks.GLASS_PANES)))
|
|
return;
|
|
|
|
BlockPos pos = event.getPos();
|
|
World world = event.getWorld();
|
|
BlockState blockState = world.getBlockState(pos);
|
|
if (!AllBlockTags.WINDOWABLE.matches(blockState))
|
|
return;
|
|
if (AllBlocks.WINDOW_IN_A_BLOCK.typeOf(blockState))
|
|
return;
|
|
|
|
BlockState defaultState = AllBlocks.WINDOW_IN_A_BLOCK.get().getDefaultState();
|
|
world.setBlockState(pos, defaultState);
|
|
TileEntity te = world.getTileEntity(pos);
|
|
if (te != null && te instanceof WindowInABlockTileEntity) {
|
|
WindowInABlockTileEntity wte = (WindowInABlockTileEntity) te;
|
|
wte.setWindowBlock(item.getBlock().getDefaultState());
|
|
wte.updateWindowConnections();
|
|
|
|
if (blockState.getBlock() instanceof FourWayBlock) {
|
|
for (BooleanProperty side : Arrays.asList(FourWayBlock.EAST, FourWayBlock.NORTH, FourWayBlock.SOUTH,
|
|
FourWayBlock.WEST))
|
|
blockState = blockState.with(side, false);
|
|
}
|
|
if (blockState.getBlock() instanceof WallBlock)
|
|
blockState = blockState.with(WallBlock.UP, true);
|
|
|
|
wte.setPartialBlock(blockState);
|
|
wte.requestModelDataUpdate();
|
|
|
|
if (!event.getPlayer().isCreative())
|
|
stack.shrink(1);
|
|
event.getPlayer().swingArm(event.getHand());
|
|
}
|
|
|
|
event.setCanceled(true);
|
|
}
|
|
|
|
}
|