init commit

This commit is contained in:
Xevion
2019-07-06 18:21:18 -05:00
parent 1962995275
commit d6966bd75f
18 changed files with 259 additions and 27 deletions

View File

@@ -0,0 +1,4 @@
package net.fabricmc.example;
public class CraftingWand {
}

View File

@@ -0,0 +1,11 @@
package net.fabricmc.example;
import net.fabricmc.api.ModInitializer;
public class ExampleMod implements ModInitializer {
@Override
public void onInitialize() {
Wands.register();
System.out.println("Wand Items Registered");
}
}

View File

@@ -1,14 +0,0 @@
package net.fabricmc.example;
import net.fabricmc.api.ModInitializer;
public class ExampleMod implements ModInitializer {
@Override
public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
System.out.println("Hello Fabric world!");
}
}

View File

@@ -0,0 +1,4 @@
package net.fabricmc.example;
public class WandCraftingTableContainer {
}

View File

@@ -0,0 +1,4 @@
package net.fabricmc.example;
public class Wands {
}

View File

@@ -0,0 +1,11 @@
package xevion.everythingonastick;
import net.fabricmc.api.ModInitializer;
public class EverythingOnAStick implements ModInitializer {
@Override
public void onInitialize() {
RegisterWands.register();
System.out.println("Wand Items Registered");
}
}

View File

@@ -0,0 +1,28 @@
package xevion.everythingonastick;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import xevion.everythingonastick.craftingtable.CraftingWandItem;
import xevion.everythingonastick.enchantingtable.EnchantingTableWandItem;
import xevion.everythingonastick.enderchest.EnderchestWandItem;
import xevion.everythingonastick.furnace.FurnaceWandItem;
public class RegisterWands {
static final CraftingWandItem CRAFTING_WAND = new CraftingWandItem(new Item.Settings().group(ItemGroup.TOOLS));
static final FurnaceWandItem FURNACE_WAND = new FurnaceWandItem(new Item.Settings().group(ItemGroup.TOOLS));
static final EnderchestWandItem ENDERCHEST_WAND = new EnderchestWandItem(new Item.Settings().group(ItemGroup.TOOLS));
static final EnchantingTableWandItem ENCHANTING_TABLE_WAND = new EnchantingTableWandItem(new Item.Settings().group(ItemGroup.TOOLS));
public static void register() {
register("crafting-table-on-a-stick", CRAFTING_WAND);
register("furnace-on-a-stick", FURNACE_WAND);
register("enderchest-on-a-stick", ENDERCHEST_WAND);
register("enchanting-table-on-a-stick", ENCHANTING_TABLE_WAND);
}
public static void register(String name, Item item) {
Registry.register(Registry.ITEM, new Identifier("everything-on-a-stick", name), item);
}
}

View File

@@ -0,0 +1,17 @@
package xevion.everythingonastick.craftingtable;
import net.minecraft.container.BlockContext;
import net.minecraft.container.CraftingTableContainer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
public class CraftingWandContainer extends CraftingTableContainer {
public CraftingWandContainer(int sync_id, PlayerInventory player_inventory, BlockContext block_context) {
super(sync_id, player_inventory, block_context);
}
@Override
public boolean canUse(PlayerEntity player) {
return true;
}
}

View File

@@ -0,0 +1,34 @@
package xevion.everythingonastick.craftingtable;
import net.minecraft.client.network.ClientDummyContainerProvider;
import net.minecraft.container.BlockContext;
import net.minecraft.container.NameableContainerProvider;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class CraftingWandItem extends Item {
public CraftingWandItem(Settings settings) {
super(settings);
};
private static final Text container_title = new TranslatableText("container.crafting", new Object[0]);
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
if(!world.isClient()) {
player.openContainer(getProvider(world, player.getBlockPos()));
}
return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand));
}
private NameableContainerProvider getProvider(World world, BlockPos blockpos) {
return new ClientDummyContainerProvider((sync_id, player_inventory, player) -> new CraftingWandContainer(sync_id, player_inventory, BlockContext.create(world, blockpos)), container_title);
}
}

View File

@@ -0,0 +1,33 @@
package xevion.everythingonastick.enderchest;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.block.entity.EnchantingTableBlockEntity;
import net.minecraft.client.network.ClientDummyContainerProvider;
import net.minecraft.container.BlockContext;
import net.minecraft.container.EnchantingTableContainer;
import net.minecraft.container.NameableContainerProvider;
import net.minecraft.text.Text;
import net.minecraft.util.Nameable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class EnderchestWandBlockEntity extends EnchantingTableBlockEntity {
public EnderchestWandBlockEntity() {}
@Override
public void tick() {}
public NameableContainerProvider createContainerProvider(BlockState blockState_1, World world_1, BlockPos blockPos_1) {
if (blockEntity_1 instanceof EnchantingTableBlockEntity) {
Text text_1 = ((Nameable)blockEntity_1).getDisplayName();
return new ClientDummyContainerProvider((int_1, playerInventory_1, playerEntity_1) -> {
return new EnchantingTableContainer(int_1, playerInventory_1, BlockContext.create(world_1, blockPos_1));
}, text_1);
} else {
return null;
}
}
}

View File

@@ -0,0 +1,4 @@
package xevion.everythingonastick.enchantingtable;
public class EnchantingTableWandItem {
}

View File

@@ -0,0 +1,34 @@
package xevion.everythingonastick.enderchest;
import net.minecraft.client.network.ClientDummyContainerProvider;
import net.minecraft.container.BlockContext;
import net.minecraft.container.GenericContainer;
import net.minecraft.container.NameableContainerProvider;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import xevion.everythingonastick.craftingtable.WandCraftingTableContainer;
import static net.minecraft.block.EnderChestBlock.CONTAINER_NAME;
public class EnderchestWand extends Item {
public EnderchestWand(Settings settings) {
super(settings);
};
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
if(!world.isClient()) {
player.openContainer(new ClientDummyContainerProvider((int_1, playerInventory_1, playerEntity_1x) -> {
return GenericContainer.createGeneric9x3(int_1, playerInventory_1, player.getEnderChestInventory());
}, CONTAINER_NAME));
}
return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand));
}
}

View File

@@ -0,0 +1,4 @@
package xevion.everythingonastick.furnace;
public class CustomAbstractFurnaceBlockEntity {
}

View File

@@ -0,0 +1,39 @@
package xevion.everythingonastick.furnace;
import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.container.Container;
import net.minecraft.container.FurnaceContainer;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.recipe.RecipeType;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
public class WandFurnaceBlockEntity extends AbstractFurnaceBlockEntity {
public WandFurnaceBlockEntity() {super(BlockEntityType.FURNACE, RecipeType.SMELTING); }
public Text getContainerName() {
return new TranslatableText("container.furnacewand", new Object[0]);
}
protected Container createContainer(int int_1, PlayerInventory playerInventory_1) {
return new FurnaceContainer(int_1, playerInventory_1, this, this.propertyDelegate);
}
public boolean canPlayerUseInv(PlayerEntity player) {
return true;
}
//
// public int[] getInvAvailableSlots(Direction direction_1) {
// return new int[]{};
// }
//
// public boolean canInsertInvStack(int int_1, ItemStack itemStack_1, @Nullable Direction direction_1) {
// return false;
// }
//
// public boolean canExtractInvStack(int int_1, ItemStack itemStack_1, Direction direction_1) {
// return false;
// }
}

View File

@@ -0,0 +1,26 @@
package xevion.everythingonastick.furnace;
import net.minecraft.container.NameableContainerProvider;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
public class FurnaceWand extends Item {
public FurnaceWand(Settings settings) {
super(settings);
};
private WandFurnaceBlockEntity block_entity = new WandFurnaceBlockEntity();
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
if(!world.isClient()) {
player.openContainer((NameableContainerProvider)block_entity);
}
return new TypedActionResult<>(ActionResult.SUCCESS, player.getStackInHand(hand));
}
}

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -0,0 +1,6 @@
{
"item.everything-on-a-stick.crafting-table-on-a-stick" : "Crafting Table on a Stick",
"item.everything-on-a-stick.furnace-on-a-stick" : "Furnace on a Stick",
"item.everything-on-a-stick.enderchest-on-a-stick" : "Enderchest on a Stick",
"item.everything-on-a-stick.enchanting-table-on-a-stick" : "Enchanting Table on a Stick"
}

View File

@@ -1,13 +0,0 @@
{
"required": true,
"package": "net.fabricmc.example.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
],
"client": [
"ExampleMixin"
],
"injectors": {
"defaultRequire": 1
}
}