mirror of
https://github.com/GTNewHorizons/StorageDrawers.git
synced 2026-11-19 11:59:19 +00:00
moved logic to TE side
This commit is contained in:
1 parent
02e108e75d
commit
5963ae9c10
8 files changed
+65
-262
No files matched your search
+2
-2
@@ -83,7 +83,7 @@ apiPackage = api
|
||||
accessTransformersFile = storagedrawers_at.cfg
|
||||
|
||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
||||
usesMixins = true
|
||||
usesMixins = false
|
||||
|
||||
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
|
||||
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
|
||||
@@ -104,7 +104,7 @@ mixinsPackage = mixins
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
# This parameter is for legacy compatibility only
|
||||
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
|
||||
coreModClass = mixins.EarlyMixinsLoader
|
||||
coreModClass =
|
||||
|
||||
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
|
||||
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
|
||||
|
||||
@@ -72,7 +72,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import fox.spiteful.avaritia.items.ItemMatterCluster;
|
||||
import xonin.backhand.api.core.BackhandUtils;
|
||||
|
||||
public class BlockDrawers extends BlockContainer implements IExtendedBlockClickHandler, INetworked {
|
||||
public class BlockDrawers extends BlockContainer implements INetworked {
|
||||
|
||||
private static final ResourceLocation blockConfig = new ResourceLocation(
|
||||
StorageDrawers.MOD_ID + ":textures/blocks/block_config.mcmeta");
|
||||
@@ -477,78 +477,6 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
|
||||
if (world.isRemote) {
|
||||
MovingObjectPosition posn = Minecraft.getMinecraft().objectMouseOver;
|
||||
float hitX = (float) (posn.hitVec.xCoord - posn.blockX);
|
||||
float hitY = (float) (posn.hitVec.yCoord - posn.blockY);
|
||||
float hitZ = (float) (posn.hitVec.zCoord - posn.blockZ);
|
||||
|
||||
StorageDrawers.network.sendToServer(
|
||||
new BlockClickMessage(
|
||||
x,
|
||||
y,
|
||||
z,
|
||||
posn.sideHit,
|
||||
hitX,
|
||||
hitY,
|
||||
hitZ,
|
||||
StorageDrawers.config.cache.invertShift));
|
||||
|
||||
if (StorageDrawers.config.cache.debugTrace)
|
||||
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "BlockDrawers.onBlockClicked with " + posn);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY,
|
||||
float hitZ, boolean invertShift) {
|
||||
if (StorageDrawers.config.cache.debugTrace)
|
||||
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "IExtendedBlockClickHandler.onBlockClicked");
|
||||
|
||||
if (!player.capabilities.isCreativeMode) {
|
||||
PlayerInteractEvent event = ForgeEventFactory
|
||||
.onPlayerInteract(player, PlayerInteractEvent.Action.LEFT_CLICK_BLOCK, x, y, z, side, world);
|
||||
if (event.isCanceled()) return;
|
||||
}
|
||||
|
||||
TileEntityDrawers tileDrawers = getTileEntitySafe(world, x, y, z);
|
||||
|
||||
if (tileDrawers.getDirection() != side) return;
|
||||
|
||||
if (tileDrawers.isSealed()) return;
|
||||
|
||||
if (!SecurityManager.hasAccess(player.getGameProfile(), tileDrawers)) return;
|
||||
|
||||
// int slot = getDrawerSlot(side, hitX, hitY, hitZ);
|
||||
// IDrawer drawer = tileDrawers.getDrawer(slot);
|
||||
// if (drawer == null) return;
|
||||
//
|
||||
// final ItemStack item;
|
||||
// // if invertSHift is true this will happen when the player is not shifting
|
||||
// if (player.isSneaking() != invertShift)
|
||||
// item = tileDrawers.takeItemsFromSlot(slot, drawer.getStoredItemStackSize());
|
||||
// else item = tileDrawers.takeItemsFromSlot(slot, 1);
|
||||
//
|
||||
// if (StorageDrawers.config.cache.debugTrace)
|
||||
// FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, (item == null) ? " null item" : " " + item);
|
||||
//
|
||||
// if (item != null && item.stackSize > 0) {
|
||||
// if (!player.inventory.addItemStackToInventory(item)) {
|
||||
// ForgeDirection dir = ForgeDirection.getOrientation(side);
|
||||
// dropItemStack(world, x + dir.offsetX, y, z + dir.offsetZ, item);
|
||||
// world.markBlockForUpdate(x, y, z);
|
||||
// } else world.playSoundEffect(
|
||||
// x + .5f,
|
||||
// y + .5f,
|
||||
// z + .5f,
|
||||
// "random.pop",
|
||||
// .2f,
|
||||
// ((world.rand.nextFloat() - world.rand.nextFloat()) * .7f + 1) * 2);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) {
|
||||
TileEntityDrawers tile = getTileEntitySafe(world, x, y, z);
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.UUID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
@@ -15,9 +16,12 @@ import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -392,6 +396,62 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe
|
||||
downgraded = state;
|
||||
}
|
||||
|
||||
public void onClick(PlayerInteractEvent event, BlockDrawers block)
|
||||
{
|
||||
int dir = getDirection();
|
||||
if (dir == event.face) {
|
||||
final int reach = 5;
|
||||
double eyeX = event.entityPlayer.posX;
|
||||
double eyeY = event.entityPlayer.posY + event.entityPlayer.getEyeHeight();
|
||||
double eyeZ = event.entityPlayer.posZ;
|
||||
|
||||
Vec3 look = event.entityPlayer.getLookVec();
|
||||
|
||||
Vec3 end = Vec3.createVectorHelper(
|
||||
eyeX + look.xCoord * reach,
|
||||
eyeY + look.yCoord * reach,
|
||||
eyeZ + look.zCoord * reach);
|
||||
|
||||
MovingObjectPosition mop = event.world
|
||||
.rayTraceBlocks(Vec3.createVectorHelper(eyeX, eyeY, eyeZ), end);
|
||||
float hitX = (float) (mop.hitVec.xCoord - mop.blockX);
|
||||
float hitY = (float) (mop.hitVec.yCoord - mop.blockY);
|
||||
float hitZ = (float) (mop.hitVec.zCoord - mop.blockZ);
|
||||
boolean invertShift = StorageDrawers.config.cache.invertShift;
|
||||
|
||||
int slot = block.getDrawerSlot(event.face, hitX, hitY, hitZ);
|
||||
IDrawer drawer = getDrawer(slot);
|
||||
if (drawer == null) return;
|
||||
final ItemStack item;
|
||||
// if invertSHift is true this will happen when the player is not shifting
|
||||
if (event.entityPlayer.isSneaking() != invertShift)
|
||||
item = takeItemsFromSlot(slot, drawer.getStoredItemStackSize());
|
||||
else item = takeItemsFromSlot(slot, 1);
|
||||
|
||||
if (StorageDrawers.config.cache.debugTrace)
|
||||
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, (item == null) ? " null item" : " " + item);
|
||||
|
||||
if (item != null && item.stackSize > 0) {
|
||||
if (!event.entityPlayer.inventory.addItemStackToInventory(item)) {
|
||||
ForgeDirection dir2 = ForgeDirection.getOrientation(event.face);
|
||||
block.dropItemStack(
|
||||
event.world,
|
||||
event.x + dir2.offsetX,
|
||||
event.y,
|
||||
event.z + dir2.offsetZ,
|
||||
item);
|
||||
event.world.markBlockForUpdate(event.x, event.y, event.z);
|
||||
} else event.world.playSoundEffect(
|
||||
event.x + .5f,
|
||||
event.y + .5f,
|
||||
event.z + .5f,
|
||||
"random.pop",
|
||||
.2f,
|
||||
((event.world.rand.nextFloat() - event.world.rand.nextFloat()) * .7f + 1) * 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isVoid() {
|
||||
if (!StorageDrawers.config.cache.enableVoidUpgrades) return false;
|
||||
|
||||
|
||||
@@ -25,59 +25,8 @@ public class ForgeEventHandler {
|
||||
TileEntity mystery_tile = event.world.getTileEntity(event.x, event.y, event.z);
|
||||
if (mystery_tile instanceof TileEntityDrawers tile
|
||||
&& event.world.getBlock(event.x, event.y, event.z) instanceof BlockDrawers block) {
|
||||
int dir = tile.getDirection();
|
||||
if (dir == event.face) {
|
||||
final int reach = 5;
|
||||
double eyeX = event.entityPlayer.posX;
|
||||
double eyeY = event.entityPlayer.posY + event.entityPlayer.getEyeHeight();
|
||||
double eyeZ = event.entityPlayer.posZ;
|
||||
|
||||
Vec3 look = event.entityPlayer.getLookVec();
|
||||
|
||||
Vec3 end = Vec3.createVectorHelper(
|
||||
eyeX + look.xCoord * reach,
|
||||
eyeY + look.yCoord * reach,
|
||||
eyeZ + look.zCoord * reach);
|
||||
|
||||
MovingObjectPosition mop = event.world
|
||||
.rayTraceBlocks(Vec3.createVectorHelper(eyeX, eyeY, eyeZ), end);
|
||||
float hitX = (float) (mop.hitVec.xCoord - mop.blockX);
|
||||
float hitY = (float) (mop.hitVec.yCoord - mop.blockY);
|
||||
float hitZ = (float) (mop.hitVec.zCoord - mop.blockZ);
|
||||
boolean invertShift = StorageDrawers.config.cache.invertShift;
|
||||
|
||||
int slot = block.getDrawerSlot(event.face, hitX, hitY, hitZ);
|
||||
IDrawer drawer = tile.getDrawer(slot);
|
||||
if (drawer == null) return;
|
||||
final ItemStack item;
|
||||
// if invertSHift is true this will happen when the player is not shifting
|
||||
if (event.entityPlayer.isSneaking() != invertShift)
|
||||
item = tile.takeItemsFromSlot(slot, drawer.getStoredItemStackSize());
|
||||
else item = tile.takeItemsFromSlot(slot, 1);
|
||||
|
||||
if (StorageDrawers.config.cache.debugTrace)
|
||||
FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, (item == null) ? " null item" : " " + item);
|
||||
|
||||
if (item != null && item.stackSize > 0) {
|
||||
if (!event.entityPlayer.inventory.addItemStackToInventory(item)) {
|
||||
ForgeDirection dir2 = ForgeDirection.getOrientation(event.face);
|
||||
block.dropItemStack(
|
||||
event.world,
|
||||
event.x + dir2.offsetX,
|
||||
event.y,
|
||||
event.z + dir2.offsetZ,
|
||||
item);
|
||||
event.world.markBlockForUpdate(event.x, event.y, event.z);
|
||||
} else event.world.playSoundEffect(
|
||||
event.x + .5f,
|
||||
event.y + .5f,
|
||||
event.z + .5f,
|
||||
"random.pop",
|
||||
.2f,
|
||||
((event.world.rand.nextFloat() - event.world.rand.nextFloat()) * .7f + 1) * 2);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
tile.onClick(event, block);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.mixins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.gtnewhorizon.gtnhmixins.IEarlyMixinLoader;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.IMixins;
|
||||
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
|
||||
@IFMLLoadingPlugin.MCVersion("1.7.10")
|
||||
public class EarlyMixinsLoader implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModContainerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSetupClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {}
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMixinConfig() {
|
||||
// rename the associated .json file by replacing the "mymodid" with your own mod ID
|
||||
// in the .json file edit the "package" and "refmap" properties to match your mod
|
||||
// also edit the "refmap" property in the "mixins.mymodid.json" file
|
||||
return "mixins.storagedrawers.early.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMixins(Set<String> loadedCoreMods) {
|
||||
return IMixins.getEarlyMixins(Mixins.class, loadedCoreMods);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.mixins;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.gtnewhorizon.gtnhmixins.builders.IMixins;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.MixinBuilder;
|
||||
|
||||
public enum Mixins implements IMixins {
|
||||
|
||||
// Read the java doc of IMixins and MixinBuilder for further information
|
||||
|
||||
// You should declare all of your mixins early and late in this same enum
|
||||
|
||||
MIXIN_PLAYER_CONTROLLER(new MixinBuilder().setPhase(Phase.EARLY).addClientMixins("MixinPlayerControllerMP"));
|
||||
|
||||
private final MixinBuilder builder;
|
||||
|
||||
Mixins(MixinBuilder builder) {
|
||||
this.builder = builder;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public MixinBuilder getBuilder() {
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.mixins;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.gtnewhorizon.gtnhmixins.builders.ITargetMod;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.TargetModBuilder;
|
||||
|
||||
public enum TargetMods implements ITargetMod {
|
||||
|
||||
// Read the java doc of ITargetMod and TargetModBuilder for further information
|
||||
|
||||
// Add to this enum information about the mods you need to identify during runtime
|
||||
|
||||
COFHCORE("cofh.asm.LoadingPlugin", "CoFHCore"),
|
||||
OPTIFINE("optifine.OptiFineForgeTweaker", "Optifine");
|
||||
|
||||
private final TargetModBuilder builder;
|
||||
|
||||
TargetMods(String coreModClass, String modId) {
|
||||
this.builder = new TargetModBuilder().setCoreModClass(coreModClass).setModId(modId);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TargetModBuilder getBuilder() {
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
package com.jaquadro.minecraft.storagedrawers.mixins.early;
|
||||
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(PlayerControllerMP.class)
|
||||
public abstract class MixinPlayerControllerMP {
|
||||
|
||||
// @Shadow
|
||||
// private Minecraft mc;
|
||||
//
|
||||
// @Inject(
|
||||
// method = "onPlayerDamageBlock",
|
||||
// at = @At(
|
||||
// value = "INVOKE_ASSIGN",
|
||||
// target =
|
||||
// "Lnet/minecraft/block/Block;getPlayerRelativeBlockHardness(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/world/World;III)F"))
|
||||
// private void mixin(int x, int y, int z, int side, CallbackInfo ci) { // cancels block break progress and fires a
|
||||
// // click
|
||||
// // block event on the TileEntityDrawer if applicable
|
||||
// if (mc.theWorld.getTileEntity(x, y, z) instanceof TileEntityDrawers ted
|
||||
// && mc.theWorld.getBlock(x, y, z) instanceof BlockDrawers bd) {
|
||||
// if (ted.getDirection() == side) {
|
||||
// bd.onBlockClicked(mc.theWorld, x, y, z, mc.thePlayer);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
Reference in new issue
Block a user