Skip to content

Commit

Permalink
use cot object
Browse files Browse the repository at this point in the history
  • Loading branch information
friendlyhj committed Oct 12, 2020
1 parent 846efbb commit 537259f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 21 deletions.
21 changes: 13 additions & 8 deletions src/main/java/youyihj/zenutils/cotx/block/ExpandBlockContent.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package youyihj.zenutils.cotx.block;

import com.teamacronymcoders.contenttweaker.api.ctobjects.blockpos.MCBlockPos;
import com.teamacronymcoders.contenttweaker.api.ctobjects.blockstate.MCBlockState;
import com.teamacronymcoders.contenttweaker.api.ctobjects.entity.EntityHelper;
import com.teamacronymcoders.contenttweaker.api.ctobjects.entity.player.CTPlayer;
import com.teamacronymcoders.contenttweaker.api.ctobjects.enums.Facing;
import com.teamacronymcoders.contenttweaker.api.ctobjects.enums.Hand;
import com.teamacronymcoders.contenttweaker.api.ctobjects.world.MCWorld;
import com.teamacronymcoders.contenttweaker.modules.vanilla.blocks.BlockContent;
import crafttweaker.api.minecraft.CraftTweakerMC;
import crafttweaker.mc1120.util.MCPosition3f;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
Expand All @@ -26,27 +31,27 @@ public ExpandBlockContent(ExpandBlockRepresentation blockRepresentation) {
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
return Objects.nonNull(expandBlockRepresentation.onBlockActivated) &&
expandBlockRepresentation.onBlockActivated.activate(
CraftTweakerMC.getIWorld(worldIn),
CraftTweakerMC.getIBlockPos(pos),
CraftTweakerMC.getBlockState(state),
CraftTweakerMC.getIPlayer(playerIn),
new MCWorld(worldIn),
new MCBlockPos(pos),
new MCBlockState(state),
new CTPlayer(playerIn),
Hand.of(hand),
Facing.of(facing),
new float[]{hitX, hitY, hitZ}
new MCPosition3f(hitX, hitY, hitZ)
);
}

@Override
public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn) {
if (Objects.nonNull(expandBlockRepresentation.onEntityWalk)) {
expandBlockRepresentation.onEntityWalk.call(CraftTweakerMC.getIWorld(worldIn), CraftTweakerMC.getIBlockPos(pos), CraftTweakerMC.getIEntity(entityIn));
expandBlockRepresentation.onEntityWalk.call(new MCWorld(worldIn), new MCBlockPos(pos), EntityHelper.getIEntity(entityIn));
}
}

@Override
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
if (Objects.nonNull(expandBlockRepresentation.onEntityCollidedWithBlock)) {
expandBlockRepresentation.onEntityCollidedWithBlock.call(CraftTweakerMC.getIWorld(worldIn), CraftTweakerMC.getIBlockPos(pos), CraftTweakerMC.getBlockState(state),CraftTweakerMC.getIEntity(entityIn));
expandBlockRepresentation.onEntityCollidedWithBlock.call(new MCWorld(worldIn), new MCBlockPos(pos), new MCBlockState(state), EntityHelper.getIEntity(entityIn));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package youyihj.zenutils.cotx.function;

import com.teamacronymcoders.contenttweaker.api.ctobjects.blockpos.IBlockPos;
import com.teamacronymcoders.contenttweaker.api.ctobjects.blockstate.ICTBlockState;
import com.teamacronymcoders.contenttweaker.api.ctobjects.entity.player.ICTPlayer;
import com.teamacronymcoders.contenttweaker.api.ctobjects.enums.Facing;
import com.teamacronymcoders.contenttweaker.api.ctobjects.enums.Hand;
import com.teamacronymcoders.contenttweaker.api.ctobjects.world.IWorld;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.block.IBlockState;
import crafttweaker.api.player.IPlayer;
import crafttweaker.api.world.IBlockPos;
import crafttweaker.api.world.IWorld;
import crafttweaker.api.util.Position3f;
import stanhebben.zenscript.annotations.ZenClass;

@FunctionalInterface
@ZenRegister
@ModOnly("contenttweaker")
@ZenClass("mods.zenutils.cotx.IBlockActivated")
public interface IBlockActivated {
boolean activate(IWorld world, IBlockPos pos, IBlockState state, IPlayer player, Hand hand, Facing facing, float[] blockHit);
boolean activate(IWorld world, IBlockPos pos, ICTBlockState state, ICTPlayer player, Hand hand, Facing facing, Position3f blockHit);
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package youyihj.zenutils.cotx.function;

import com.teamacronymcoders.contenttweaker.api.ctobjects.blockpos.IBlockPos;
import com.teamacronymcoders.contenttweaker.api.ctobjects.blockstate.ICTBlockState;
import com.teamacronymcoders.contenttweaker.api.ctobjects.world.IWorld;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.block.IBlockState;
import crafttweaker.api.entity.IEntity;
import crafttweaker.api.world.IBlockPos;
import crafttweaker.api.world.IWorld;
import stanhebben.zenscript.annotations.ZenClass;

@FunctionalInterface
@ZenRegister
@ZenClass("mods.zenutils.cotx.IEntityCollided")
public interface IEntityCollided {
void call(IWorld world, IBlockPos pos, IBlockState state, IEntity entity);
void call(IWorld world, IBlockPos pos, ICTBlockState state, IEntity entity);
}
4 changes: 2 additions & 2 deletions src/main/java/youyihj/zenutils/cotx/function/IEntityWalk.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package youyihj.zenutils.cotx.function;

import com.teamacronymcoders.contenttweaker.api.ctobjects.blockpos.IBlockPos;
import com.teamacronymcoders.contenttweaker.api.ctobjects.world.IWorld;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.entity.IEntity;
import crafttweaker.api.world.IBlockPos;
import crafttweaker.api.world.IWorld;
import stanhebben.zenscript.annotations.ZenClass;

@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package youyihj.zenutils.cotx.function;

import com.teamacronymcoders.contenttweaker.api.ctobjects.world.IWorld;
import crafttweaker.annotations.ModOnly;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.item.IItemStack;
import crafttweaker.api.world.IWorld;
import stanhebben.zenscript.annotations.ZenClass;

@FunctionalInterface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package youyihj.zenutils.cotx.item;

import com.teamacronymcoders.contenttweaker.api.ctobjects.world.MCWorld;
import com.teamacronymcoders.contenttweaker.modules.vanilla.items.ItemContent;
import crafttweaker.api.minecraft.CraftTweakerMC;
import net.minecraft.entity.item.EntityItem;
Expand All @@ -25,6 +26,6 @@ public boolean onEntityItemUpdate(EntityItem entityItem) {
@Override
public int getEntityLifespan(ItemStack itemStack, World world) {
if (Objects.isNull(expandItemRepresentation.getEntityLifeSpan)) return super.getEntityLifespan(itemStack, world);
return expandItemRepresentation.getEntityLifeSpan.get(CraftTweakerMC.getIItemStack(itemStack), CraftTweakerMC.getIWorld(world));
return expandItemRepresentation.getEntityLifeSpan.get(CraftTweakerMC.getIItemStack(itemStack), new MCWorld(world));
}
}

0 comments on commit 537259f

Please sign in to comment.