Skip to content

Commit 4dd0afb

Browse files
committed
Added getBlock/getBlockMetadata methods to Vec3i.
Misc adjustments.
1 parent 83fb1ac commit 4dd0afb

File tree

8 files changed

+36
-7
lines changed

8 files changed

+36
-7
lines changed

multiblocks/src/main/java/sunsetsatellite/catalyst/multiblocks/RenderMultiblock.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void doRender(Tessellator tessellator, TileEntity tileEntity, double d, d
2020
int i = tileEntity.x;
2121
int j = tileEntity.y;
2222
int k = tileEntity.z;
23-
Direction dir = Direction.getDirectionFromSide(tileEntity.getMovedData()).getOpposite();
23+
Direction dir = Direction.getDirectionFromSide(tileEntity.getMovedData());
2424
World world = this.renderDispatcher.renderEngine.mc.theWorld;
2525
if(tileEntity instanceof IMultiblock){
2626
Multiblock multiblock = ((IMultiblock) tileEntity).getMultiblock();

multipart/src/main/java/sunsetsatellite/catalyst/multipart/block/BlockCarpenterWorkbench.java

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ protected TileEntity getNewBlockEntity() {
2424
return new TileEntityCarpenterWorkbench();
2525
}
2626

27+
@Override
2728
public boolean onBlockRightClicked(World world, int i, int j, int k, EntityPlayer entityplayer, Side side, double xHit, double yHit) {
2829
if (world.isClientSide) {
2930
return true;

multipart/src/main/java/sunsetsatellite/catalyst/multipart/item/ItemMultipart.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package sunsetsatellite.catalyst.multipart.item;
22

33
import com.mojang.nbt.CompoundTag;
4+
import net.minecraft.client.Minecraft;
45
import net.minecraft.core.block.Block;
56
import net.minecraft.core.block.BlockFluid;
67
import net.minecraft.core.block.entity.TileEntity;
@@ -72,7 +73,7 @@ public Multipart getMultipart(ItemStack itemstack) {
7273
public boolean onUseItemOnBlock(ItemStack stack, EntityPlayer player, World world, int blockX, int blockY, int blockZ, Side side, double xPlaced, double yPlaced) {
7374
Multipart multipart = getMultipart(stack);
7475
if(multipart == null) return false;
75-
Pair<Direction, BlockSection> pair = Catalyst.getBlockSurfaceClickPosition(world, player);
76+
Pair<Direction, BlockSection> pair = Catalyst.getBlockSurfaceClickPosition(world, player, Minecraft.getMinecraft(this).objectMouseOver);
7677
Side playerFacing = Catalyst.calculatePlayerFacing(player.yRot);
7778
if (pairIsInvalid(pair)) return false;
7879
Direction dir = pair.getRight().toDirection(pair.getLeft(), playerFacing);

src/main/java/sunsetsatellite/catalyst/Catalyst.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package sunsetsatellite.catalyst;
22

33
import net.fabricmc.api.ModInitializer;
4-
import net.minecraft.client.Minecraft;
4+
import net.minecraft.core.Global;
55
import net.minecraft.core.HitResult;
66
import net.minecraft.core.block.entity.TileEntity;
77
import net.minecraft.core.data.registry.Registry;
@@ -44,9 +44,8 @@ public static void displayGui(EntityPlayer player, TileEntity tileEntity, String
4444
((IMpGui)player).displayCustomGUI(tileEntity, id);
4545
}
4646

47-
public static Pair<Direction,BlockSection> getBlockSurfaceClickPosition(World world, EntityPlayer player){
48-
if (!world.isClientSide) {
49-
HitResult hit = Minecraft.getMinecraft(Catalyst.class).objectMouseOver;
47+
public static Pair<Direction,BlockSection> getBlockSurfaceClickPosition(World world, EntityPlayer player, HitResult hit){
48+
if (!Global.isServer) {
5049
if(hit.hitType == HitResult.HitType.TILE){
5150
Direction dir = Direction.getDirectionFromSide(hit.side.getId());
5251
Vec3f vec3f = new Vec3f(hit.location.xCoord,hit.location.yCoord,hit.location.zCoord);

src/main/java/sunsetsatellite/catalyst/core/util/Procedure.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package sunsetsatellite.catalyst.core.util;
22

33
/**
4-
* Represents a function that accepts no arguments and produces no result.
4+
* Represents a function that accepts no arguments and produces no result besides side effects.
55
*
66
* <p>This is a functional interface
77
* whose functional method is {@link #run()}.

src/main/java/sunsetsatellite/catalyst/core/util/TickTimer.java

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package sunsetsatellite.catalyst.core.util;
22

3+
/**
4+
* A timer that calls {@link TickTimer#timeoutMethod} when {@link TickTimer#max} ticks have been counted, can be single-shot or looped.
5+
*/
36
public class TickTimer {
47
public Object owner;
58
public Procedure timeoutMethod;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package sunsetsatellite.catalyst.core.util;
2+
3+
/**
4+
* Represents a function that accepts 2 arguments + vararg argument and produces a result.
5+
*
6+
* <p>This is a functional interface
7+
* whose functional method is {@link #apply(T,T2,V...)}.
8+
*/
9+
@FunctionalInterface
10+
public interface VarargsFunction3<T,T2,V,R> {
11+
12+
/**
13+
* Runs the procedure.
14+
*/
15+
R apply(T t, T2 t2, V... args);
16+
}

src/main/java/sunsetsatellite/catalyst/core/util/Vec3i.java

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package sunsetsatellite.catalyst.core.util;
22

33
import com.mojang.nbt.CompoundTag;
4+
import net.minecraft.core.block.Block;
45
import net.minecraft.core.block.entity.TileEntity;
56
import net.minecraft.core.util.helper.MathHelper;
67
import net.minecraft.core.world.WorldSource;
@@ -226,4 +227,12 @@ public int hashCode() {
226227
public TileEntity getTileEntity(WorldSource worldSource){
227228
return worldSource.getBlockTileEntity(this.x, this.y, this.z);
228229
}
230+
231+
public Block getBlock(WorldSource worldSource){
232+
return worldSource.getBlock(this.x, this.y, this.z);
233+
}
234+
235+
public int getBlockMetadata(WorldSource worldSource){
236+
return worldSource.getBlockMetadata(this.x, this.y, this.z);
237+
}
229238
}

0 commit comments

Comments
 (0)