Compare commits

..

2 Commits

6 changed files with 88 additions and 13 deletions

View File

@ -18,14 +18,16 @@ public class MainMod implements ModInitializer {
if (ModConfig.ENABLE_WHITE_WOOL_RECIPE.get()) {
for (int colorId = 0; colorId < 16; ++colorId) {
WyHelper.addShapelessRecipe(new ItemInstance(Tile.WOOL, 1, 0), new Object[]{
new ItemInstance(Tile.WOOL, 1, WoolTile.method_2(colorId)), new ItemInstance(ItemType.dyePowder, 1, 15)});
WyHelper.addShapelessRecipe(new ItemInstance(Tile.WOOL, 1, 0), new ItemInstance(Tile.WOOL, 1, WoolTile.method_2(colorId)),
new ItemInstance(ItemType.dyePowder, 1, 15));
}
}
if (ModConfig.ENABLE_COAL_AND_REDSTONE_BLOCKS_RECIPE.get()) {
WyHelper.addShapedRecipe(new ItemInstance(ModTile.COAL_BLOCK, 1, 0), "###", "###", "###", '#', ItemType.coal);
WyHelper.addShapelessRecipe(new ItemInstance(ItemType.coal, 9), new ItemInstance(ModTile.COAL_BLOCK, 1));
WyHelper.addShapedRecipe(new ItemInstance(ModTile.REDSTONE_BLOCK, 1, 0), "###", "###", "###", '#', ItemType.redstone);
WyHelper.addShapelessRecipe(new ItemInstance(ItemType.redstone, 9), new ItemInstance(ModTile.REDSTONE_BLOCK, 1));
}
}
}

View File

@ -6,6 +6,7 @@ import java.util.HashMap;
import net.minecraft.entity.player.Player;
import net.minecraft.item.ItemInstance;
import net.minecraft.item.ItemType;
import net.minecraft.recipe.RecipeRegistry;
import xyz.pixelatedw.finalbeta.mixin.MinecraftAccessorMixin;
import xyz.pixelatedw.finalbeta.mixin.RecipeRegistryAccessorMixin;
@ -64,10 +65,11 @@ public class WyHelper {
// player.level.entities.stream().filter(e -> !(e instanceof Player)).forEach((e) -> ((net.minecraft.entity.Entity)e).remove());
// player.dropItem(new ItemInstance(Tile.LADDER, 64));
// player.dropItem(new ItemInstance(Tile.STONE_SLAB, 64));
// player.dropItem(new ItemInstance(Tile.SLAB, 64));
// player.dropItem(new ItemInstance(ItemType.minecart, 1));
// player.dropItem(new ItemInstance(ItemType.minecartFurnace, 1));
// player.dropItem(new ItemInstance(ItemType.coal, 64));
player.dropItem(new ItemInstance(ItemType.hatchetDiamond, 1));
// player.dropItem(new ItemInstance(Tile.GOLDEN_RAIL, 64));
// player.dropItem(new ItemInstance(Tile.COBBLESTONE, 64));
@ -81,10 +83,10 @@ public class WyHelper {
// player.level.setTile(x + i, y, z, Tile.REDSTONE_TORCH_LIT.id);
// }
// player.level.setLevelTime(0);
// player.level.getProperties().setRaining(false);
// player.level.getProperties().setRainTime(0);
// player.level.getProperties().setThundering(false);
// player.level.getProperties().setThunderTime(0);
player.level.setLevelTime(0);
player.level.getProperties().setRaining(false);
player.level.getProperties().setRainTime(0);
player.level.getProperties().setThundering(false);
player.level.getProperties().setThunderTime(0);
}
}

View File

@ -37,6 +37,8 @@ public class FenceTileMixin extends Tile {
}
private Box createFenceBox(Level level, int x, int y, int z, boolean isOutline) {
Tile tile = ((FenceTile)(Object)this);
boolean eastCheck = level.getMaterial(x + 1, y, z).isSolid();
boolean westCheck = level.getMaterial(x - 1, y, z).isSolid();
boolean southCheck = level.getMaterial(x, y, z + 1).isSolid();
@ -44,6 +46,13 @@ public class FenceTileMixin extends Tile {
Box box = Box.create(westCheck ? 0 : 0.375f, 0.0f, northCheck ? 0.0f : 0.375f, eastCheck ? 1.0f : 0.625f, 1.0F, southCheck ? 1.0f : 0.625f);
tile.minX = westCheck ? 0 : 0.375f;
tile.minY = 0.0;
tile.minZ = northCheck ? 0.0f : 0.375f;
tile.maxX = eastCheck ? 1.0f : 0.625f;
tile.maxY = 1.0f;
tile.maxZ = southCheck ? 1.0f : 0.625f;
box.minX += x;
box.minY += y;
box.minZ += z;

View File

@ -5,15 +5,21 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.entity.FurnaceEntity;
import net.minecraft.item.ItemInstance;
import net.minecraft.item.ItemType;
import net.minecraft.util.io.CompoundTag;
import xyz.pixelatedw.finalbeta.ModConfig;
import xyz.pixelatedw.finalbeta.ModTile;
@Mixin(FurnaceEntity.class)
public class FurnaceEntityMixin {
@Shadow
public int fuelTime;
@Shadow
private ItemInstance[] contents;
@ -26,4 +32,34 @@ public class FurnaceEntityMixin {
}
}
}
@Inject(method = "getFuelTime", at = @At("HEAD"), cancellable = true)
private void getFuelTime(ItemInstance stack, CallbackInfoReturnable<Integer> cir) {
if (stack == null) {
cir.setReturnValue(0);
return;
}
if (stack.getType().id == ModTile.COAL_BLOCK.id) {
cir.setReturnValue(16000);
return;
}
}
/*
* Properly saving and loading the fuelTime as otherwise minecraft tries to
* get it from the fuel item slot, which can be empty...and so the fuel time
* defaults to 200. By saving it we make sure the fuel time is always
* correct regardless of the fuel slot contents.
*/
@Inject(method = "writeIdentifyingData", at = @At("TAIL"))
public void writeIdentifyingData(CompoundTag tag, CallbackInfo ci) {
tag.put("FuelTime", this.fuelTime);
}
@Inject(method = "readIdentifyingData", at = @At("TAIL"))
public void readIdentifyingData(CompoundTag tag, CallbackInfo ci) {
this.fuelTime = tag.getInt("FuelTime");
}
}

View File

@ -7,9 +7,13 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemInstance;
import net.minecraft.item.ItemType;
import net.minecraft.item.tool.HatchetItem;
import net.minecraft.tile.Tile;
import xyz.pixelatedw.finalbeta.ModConfig;
@Mixin(ItemInstance.class)
@ -20,6 +24,9 @@ public class ItemInstanceMixin {
@Shadow
private int damage;
@Shadow
public int itemId;
@Inject(method = "applyDamage", at = @At("HEAD"))
public void applyDamage(int i, Entity arg, CallbackInfo ci) {
if(ModConfig.ADD_MORE_SOUNDS.get()) {
@ -29,4 +36,15 @@ public class ItemInstanceMixin {
}
}
}
@Inject(method = "isEffectiveOn", at = @At("HEAD"), cancellable = true)
public void isEffectiveOn(Tile tile, CallbackInfoReturnable<Boolean> cir) {
ItemType item = ItemType.byId[this.itemId];
if (item instanceof HatchetItem && Tile.STONE_SLAB.id == tile.id) {
cir.setReturnValue(true);
return;
}
}
}

View File

@ -18,6 +18,12 @@ import xyz.pixelatedw.finalbeta.ModTile;
@Mixin(ToolItem.class)
public class ToolItemMixin {
/*
* Note that "STONE_SLAB" is actually all 4 variations of slabs in 1 block...which is stupid as fuck
* because there's no easy to check for the block and its metadata on breaking time for the bonus the
* absolute easiest and laziest way out of this is to make both pickaxes and axes effective against slabs.
*/
private static final Tile[] PICKAXE_BLOCKS = new Tile[]{Tile.COBBLESTONE, Tile.DOUBLE_STONE_SLAB, Tile.STONE_SLAB, Tile.STONE,
Tile.SANDSTONE, Tile.MOSSY_COBBLESTONE, Tile.IRON_ORE, Tile.BLOCK_IRON, Tile.COAL_ORE, Tile.BLOCK_GOLD, Tile.GOLD_ORE,
Tile.DIAMOND_ORE, Tile.BLOCK_DIAMOND, Tile.ICE, Tile.NETHERRACK, Tile.LAPIS_LAZULI_ORE, Tile.LAPIS_LAZULI_BLOCK,
@ -26,7 +32,7 @@ public class ToolItemMixin {
Tile.DISPENSER, Tile.STONE_PRESSURE_PLATE, Tile.RAIL, Tile.DETECTOR_RAIL, Tile.GOLDEN_RAIL, Tile.PISTON, Tile.STICKY_PISTON,
ModTile.COAL_BLOCK, ModTile.REDSTONE_BLOCK};
private static final Tile[] HATCHET_BLOCKS = new Tile[]{Tile.WOOD, Tile.BOOKSHELF, Tile.LOG, Tile.CHEST,
private static final Tile[] HATCHET_BLOCKS = new Tile[]{Tile.WOOD, Tile.BOOKSHELF, Tile.LOG, Tile.CHEST, Tile.STONE_SLAB,
// Here starts the list of blocks that are not affected by default
Tile.STAIRS_WOOD, Tile.DOOR_WOOD, Tile.WOODEN_PRESSURE_PLATE, Tile.JUKEBOX, Tile.NOTEBLOCK, Tile.PUMPKIN, Tile.LIT_PUMPKIN,
Tile.STANDING_SIGN, Tile.WALL_SIGN, Tile.TRAPDOOR, Tile.LADDER, Tile.WORKBENCH, Tile.FENCE};
@ -37,11 +43,13 @@ public class ToolItemMixin {
Tile.SOUL_SAND};
@Shadow
public Tile[] field_2712;
public Tile[] field_2712; // list of tiles the tool is effective against
@Shadow
public float field_2713; // bonus mining speed
@Inject(method = "<init>(IILnet/minecraft/item/tool/ToolMaterial;[Lnet/minecraft/tile/Tile;)V", at = @At("TAIL"))
public void init(int i, int j, ToolMaterial arg, Tile[] args, CallbackInfo ci) {
ToolItem tool = ((ToolItem) (Object) this);
if (tool instanceof PickaxeItem && ModConfig.FIX_PICKAXE_EFFECTIVENESS.get()) {
this.field_2712 = PICKAXE_BLOCKS;