mirror of
https://github.com/Theta-Dev/ConstructionWand.git
synced 2025-04-21 00:50:04 +02:00
Compare commits
38 commits
1.18
...
1.15.2-2.1
Author | SHA1 | Date | |
---|---|---|---|
31f549a0a0 | |||
28db271630 | |||
e5d393bce4 | |||
ccad062fd5 | |||
a59db99c4f | |||
c6f39b5378 | |||
ba5e35de04 | |||
17fd5d5fee | |||
3c5fdf5847 | |||
2abea82c76 | |||
b848742f90 | |||
3aee9629df | |||
a966a47209 | |||
cb01f789cb | |||
a29ce8cc22 | |||
a0be0884f6 | |||
40a4df7a20 | |||
7b291d514f | |||
e6e282427b | |||
0ea9cfaf46 | |||
3003cdcf18 | |||
0d90de89cf | |||
fe89f27aaa | |||
9aec266dd2 | |||
0ca8f23b69 | |||
e4ca89680d | |||
d87c7f7d1b | |||
87ab64675f | |||
b9353126eb | |||
20b016dd57 | |||
95d3c504ba | |||
4876683b07 | |||
64f947e535 | |||
cd99733803 | |||
1186043bf3 | |||
fa1587f269 | |||
e3918bc9bb | |||
89fbd5313b |
20 changed files with 84 additions and 94 deletions
|
@ -104,6 +104,10 @@ dependencies {
|
||||||
version: "${project.botania}",
|
version: "${project.botania}",
|
||||||
classifier: "api"
|
classifier: "api"
|
||||||
])
|
])
|
||||||
|
|
||||||
|
//runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.15.2-1.2-32.160")
|
||||||
|
//runtimeOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.15.2-2.0.2.4")
|
||||||
|
//runtimeOnly fg.deobf("vazkii.botania:Botania:r1.15-387.455")
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
|
|
|
@ -4,11 +4,11 @@ org.gradle.daemon=false
|
||||||
author=thetadev
|
author=thetadev
|
||||||
modid=constructionwand
|
modid=constructionwand
|
||||||
|
|
||||||
mcversion=1.16.5
|
mcversion=1.15.2
|
||||||
forgeversion=36.0.46
|
forgeversion=31.2.31
|
||||||
mcp_mappings=20200723-1.16.1
|
mcp_mappings=20200514-1.15.1
|
||||||
|
|
||||||
botania=1.16.2-405
|
botania=r1.15-387.455
|
||||||
|
|
||||||
version_major=2
|
version_major=2
|
||||||
version_minor=1
|
version_minor=1
|
|
@ -11,7 +11,7 @@
|
||||||
"conditions": {
|
"conditions": {
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"tag": "minecraft:stone_tool_materials"
|
"tag": "forge:cobblestone"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
],
|
],
|
||||||
"key": {
|
"key": {
|
||||||
"X": {
|
"X": {
|
||||||
"tag": "minecraft:stone_tool_materials"
|
"tag": "forge:cobblestone"
|
||||||
},
|
},
|
||||||
"#": {
|
"#": {
|
||||||
"tag": "forge:rods/wooden"
|
"tag": "forge:rods/wooden"
|
||||||
|
|
|
@ -82,7 +82,6 @@ public class ConstructionWand
|
||||||
renderBlockPreview = new RenderBlockPreview();
|
renderBlockPreview = new RenderBlockPreview();
|
||||||
MinecraftForge.EVENT_BUS.register(renderBlockPreview);
|
MinecraftForge.EVENT_BUS.register(renderBlockPreview);
|
||||||
MinecraftForge.EVENT_BUS.register(new ClientEvents());
|
MinecraftForge.EVENT_BUS.register(new ClientEvents());
|
||||||
ModItems.registerModelProperties();
|
|
||||||
ModItems.registerItemColors();
|
ModItems.registerItemColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,8 @@ import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.BlockItemUseContext;
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.state.Property;
|
|
||||||
import net.minecraft.state.properties.BlockStateProperties;
|
|
||||||
import net.minecraft.state.properties.SlabType;
|
|
||||||
import net.minecraft.stats.Stats;
|
import net.minecraft.stats.Stats;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.EntityPredicates;
|
import net.minecraft.util.EntityPredicates;
|
||||||
|
@ -20,9 +16,8 @@ import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
import net.minecraft.util.math.shapes.VoxelShape;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.util.BlockSnapshot;
|
import net.minecraftforge.common.util.BlockSnapshot;
|
||||||
|
@ -31,7 +26,6 @@ import thetadev.constructionwand.ConstructionWand;
|
||||||
import thetadev.constructionwand.basics.option.WandOptions;
|
import thetadev.constructionwand.basics.option.WandOptions;
|
||||||
import thetadev.constructionwand.containers.ContainerManager;
|
import thetadev.constructionwand.containers.ContainerManager;
|
||||||
import thetadev.constructionwand.items.wand.ItemWand;
|
import thetadev.constructionwand.items.wand.ItemWand;
|
||||||
import thetadev.constructionwand.wand.WandItemUseContext;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -62,12 +56,12 @@ public class WandUtil
|
||||||
return new BlockPos(player.getPositionVec());
|
return new BlockPos(player.getPositionVec());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3d entityPositionVec(Entity entity) {
|
public static Vec3d entityPositionVec(Entity entity) {
|
||||||
return new Vector3d(entity.getPosX(), entity.getPosY() - entity.getYOffset() + entity.getHeight() / 2, entity.getPosZ());
|
return new Vec3d(entity.getPosX(), entity.getPosY() - entity.getYOffset() + entity.getHeight() / 2, entity.getPosZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3d blockPosVec(BlockPos pos) {
|
public static Vec3d blockPosVec(BlockPos pos) {
|
||||||
return new Vector3d(pos.getX(), pos.getY(), pos.getZ());
|
return new Vec3d(pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ItemStack> getHotbar(PlayerEntity player) {
|
public static List<ItemStack> getHotbar(PlayerEntity player) {
|
||||||
|
@ -110,17 +104,15 @@ public class WandUtil
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean placeBlock(World world, PlayerEntity player, BlockState block, BlockPos pos, @Nullable BlockItem item) {
|
public static boolean placeBlock(World world, PlayerEntity player, BlockState block, BlockPos pos, @Nullable BlockItem item) {
|
||||||
if(!world.setBlockState(pos, block)) {
|
// Abort if placeEvent is canceled
|
||||||
ConstructionWand.LOGGER.info("Block could not be placed");
|
BlockSnapshot snapshot = new BlockSnapshot(world, pos, block);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove block if placeEvent is canceled
|
|
||||||
BlockSnapshot snapshot = BlockSnapshot.create(world.func_234923_W_(), world, pos);
|
|
||||||
BlockEvent.EntityPlaceEvent placeEvent = new BlockEvent.EntityPlaceEvent(snapshot, block, player);
|
BlockEvent.EntityPlaceEvent placeEvent = new BlockEvent.EntityPlaceEvent(snapshot, block, player);
|
||||||
MinecraftForge.EVENT_BUS.post(placeEvent);
|
MinecraftForge.EVENT_BUS.post(placeEvent);
|
||||||
if(placeEvent.isCanceled()) {
|
if(placeEvent.isCanceled()) return false;
|
||||||
world.removeBlock(pos, false);
|
|
||||||
|
// Place the block
|
||||||
|
if(!world.setBlockState(pos, block)) {
|
||||||
|
ConstructionWand.LOGGER.info("Block could not be placed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,14 +203,14 @@ public class WandUtil
|
||||||
* This check is independent from the used block.
|
* This check is independent from the used block.
|
||||||
*/
|
*/
|
||||||
public static boolean isPositionPlaceable(World world, PlayerEntity player, BlockPos pos, boolean replace) {
|
public static boolean isPositionPlaceable(World world, PlayerEntity player, BlockPos pos, boolean replace) {
|
||||||
if(!isPositionModifiable(world,player, pos)) return false;
|
if(!isPositionModifiable(world, player, pos)) return false;
|
||||||
|
|
||||||
// If replace mode is off, target has to be air
|
// If replace mode is off, target has to be air
|
||||||
return replace || world.isAirBlock(pos);
|
return replace || world.isAirBlock(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBlockRemovable(World world, PlayerEntity player, BlockPos pos) {
|
public static boolean isBlockRemovable(World world, PlayerEntity player, BlockPos pos) {
|
||||||
if(!isPositionModifiable(world,player, pos)) return false;
|
if(!isPositionModifiable(world, player, pos)) return false;
|
||||||
|
|
||||||
if(!player.isCreative()) {
|
if(!player.isCreative()) {
|
||||||
return !(world.getBlockState(pos).getBlockHardness(world, pos) <= -1) && world.getTileEntity(pos) == null;
|
return !(world.getBlockState(pos).getBlockHardness(world, pos) <= -1) && world.getTileEntity(pos) == null;
|
||||||
|
@ -235,7 +227,7 @@ public class WandUtil
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Direction fromVector(Vector3d vector) {
|
public static Direction fromVector(Vec3d vector) {
|
||||||
return Direction.getFacingFromVector(vector.x, vector.y, vector.z);
|
return Direction.getFacingFromVector(vector.x, vector.y, vector.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class RenderTypes
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.defaultBlendFunc();
|
RenderSystem.defaultBlendFunc();
|
||||||
}, RenderSystem::disableBlend);
|
}, RenderSystem::disableBlend);
|
||||||
protected static final RenderState.DepthTestState DEPTH_ALWAYS = new RenderState.DepthTestState("always", GL11.GL_ALWAYS);
|
protected static final RenderState.DepthTestState DEPTH_ALWAYS = new RenderState.DepthTestState(GL11.GL_ALWAYS);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
RenderType.State translucentNoDepthState = RenderType.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY)
|
RenderType.State translucentNoDepthState = RenderType.State.getBuilder().transparency(TRANSLUCENT_TRANSPARENCY)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package thetadev.constructionwand.client;
|
package thetadev.constructionwand.client;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.widget.button.Button;
|
import net.minecraft.client.gui.widget.button.Button;
|
||||||
|
@ -13,12 +12,13 @@ import thetadev.constructionwand.basics.option.IOption;
|
||||||
import thetadev.constructionwand.basics.option.WandOptions;
|
import thetadev.constructionwand.basics.option.WandOptions;
|
||||||
import thetadev.constructionwand.network.PacketWandOption;
|
import thetadev.constructionwand.network.PacketWandOption;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class ScreenWand extends Screen
|
public class ScreenWand extends Screen
|
||||||
{
|
{
|
||||||
private final ItemStack wand;
|
private final ItemStack wand;
|
||||||
private final WandOptions wandOptions;
|
private final WandOptions wandOptions;
|
||||||
|
private final HashMap<IOption<?>, Button> optionButtons;
|
||||||
|
|
||||||
private static final int BUTTON_WIDTH = 160;
|
private static final int BUTTON_WIDTH = 160;
|
||||||
private static final int BUTTON_HEIGHT = 20;
|
private static final int BUTTON_HEIGHT = 20;
|
||||||
|
@ -34,11 +34,13 @@ public class ScreenWand extends Screen
|
||||||
super(new StringTextComponent("ScreenWand"));
|
super(new StringTextComponent("ScreenWand"));
|
||||||
this.wand = wand;
|
this.wand = wand;
|
||||||
wandOptions = new WandOptions(wand);
|
wandOptions = new WandOptions(wand);
|
||||||
|
optionButtons = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(@Nonnull Minecraft minecraft, int width, int height) {
|
public void init(Minecraft minecraft, int width, int height) {
|
||||||
super.init(minecraft, width, height);
|
super.init(minecraft, width, height);
|
||||||
|
optionButtons.clear();
|
||||||
|
|
||||||
createButton(0, 0, wandOptions.cores);
|
createButton(0, 0, wandOptions.cores);
|
||||||
createButton(0, 1, wandOptions.lock);
|
createButton(0, 1, wandOptions.lock);
|
||||||
|
@ -49,33 +51,35 @@ public class ScreenWand extends Screen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(@Nonnull MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||||
renderBackground(matrixStack);
|
renderBackground();
|
||||||
super.render(matrixStack, mouseX, mouseY, partialTicks);
|
super.render(mouseX, mouseY, partialTicks);
|
||||||
drawCenteredString(matrixStack, font, wand.getDisplayName(), width / 2, height / 2 - FIELD_HEIGHT / 2 - SPACING_HEIGHT, 16777215);
|
drawCenteredString(font, wand.getDisplayName().getFormattedText(), width / 2, height / 2 - FIELD_HEIGHT / 2 - SPACING_HEIGHT, 16777215);
|
||||||
|
optionButtons.forEach((opt, but) -> drawTooltip(mouseX, mouseY, opt, but));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean charTyped(char character, int code) {
|
public boolean charTyped(char character, int code) {
|
||||||
if(character == 'e') closeScreen();
|
if(character == 'e') onClose();
|
||||||
return super.charTyped(character, code);
|
return super.charTyped(character, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createButton(int cx, int cy, IOption<?> option) {
|
private void createButton(int cx, int cy, IOption<?> option) {
|
||||||
Button button = new Button(getX(cx), getY(cy), BUTTON_WIDTH, BUTTON_HEIGHT, getButtonLabel(option), bt -> clickButton(bt, option), (bt, ms, x, y) -> drawTooltip(ms, x, y, option));
|
Button button = new Button(getX(cx), getY(cy), BUTTON_WIDTH, BUTTON_HEIGHT, getButtonLabel(option).getFormattedText(), bt -> clickButton(bt, option));
|
||||||
button.active = option.isEnabled();
|
button.active = option.isEnabled();
|
||||||
addButton(button);
|
addButton(button);
|
||||||
|
optionButtons.put(option, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clickButton(Button button, IOption<?> option) {
|
private void clickButton(Button button, IOption<?> option) {
|
||||||
option.next();
|
option.next();
|
||||||
ConstructionWand.instance.HANDLER.sendToServer(new PacketWandOption(option, false));
|
ConstructionWand.instance.HANDLER.sendToServer(new PacketWandOption(option, false));
|
||||||
button.setMessage(getButtonLabel(option));
|
button.setMessage(getButtonLabel(option).getFormattedText());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawTooltip(MatrixStack matrixStack, int mouseX, int mouseY, IOption<?> option) {
|
private void drawTooltip(int mouseX, int mouseY, IOption<?> option, Button button) {
|
||||||
if(isMouseOver(mouseX, mouseY)) {
|
if(button.isHovered()) {
|
||||||
renderTooltip(matrixStack, new TranslationTextComponent(option.getDescTranslation()), mouseX, mouseY);
|
renderTooltip(new TranslationTextComponent(option.getDescTranslation()).getFormattedText(), mouseX, mouseY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +92,6 @@ public class ScreenWand extends Screen
|
||||||
}
|
}
|
||||||
|
|
||||||
private ITextComponent getButtonLabel(IOption<?> option) {
|
private ITextComponent getButtonLabel(IOption<?> option) {
|
||||||
return new TranslationTextComponent(option.getKeyTranslation()).append(new TranslationTextComponent(option.getValueTranslation()));
|
return new TranslationTextComponent(option.getKeyTranslation()).appendSibling(new TranslationTextComponent(option.getValueTranslation()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package thetadev.constructionwand.data;
|
||||||
import net.minecraft.advancements.criterion.ItemPredicate;
|
import net.minecraft.advancements.criterion.ItemPredicate;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.tags.ITag;
|
import net.minecraft.tags.Tag;
|
||||||
import net.minecraft.util.IItemProvider;
|
import net.minecraft.util.IItemProvider;
|
||||||
|
|
||||||
public class Inp
|
public class Inp
|
||||||
|
@ -22,7 +22,7 @@ public class Inp
|
||||||
return new Inp(in.asItem().getRegistryName().getPath(), Ingredient.fromItems(in), ItemPredicate.Builder.create().item(in).build());
|
return new Inp(in.asItem().getRegistryName().getPath(), Ingredient.fromItems(in), ItemPredicate.Builder.create().item(in).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Inp fromTag(ITag.INamedTag<Item> in) {
|
public static Inp fromTag(Tag<Item> in) {
|
||||||
return new Inp(in.getName().getPath(), Ingredient.fromTag(in), ItemPredicate.Builder.create().tag(in).build());
|
return new Inp(in.getId().getPath(), Ingredient.fromTag(in), ItemPredicate.Builder.create().tag(in).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,8 +3,8 @@ package thetadev.constructionwand.data;
|
||||||
import net.minecraft.data.DataGenerator;
|
import net.minecraft.data.DataGenerator;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraftforge.client.model.generators.ExistingFileHelper;
|
||||||
import net.minecraftforge.client.model.generators.ItemModelProvider;
|
import net.minecraftforge.client.model.generators.ItemModelProvider;
|
||||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
|
||||||
import thetadev.constructionwand.ConstructionWand;
|
import thetadev.constructionwand.ConstructionWand;
|
||||||
import thetadev.constructionwand.items.ModItems;
|
import thetadev.constructionwand.items.ModItems;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package thetadev.constructionwand.data;
|
package thetadev.constructionwand.data;
|
||||||
|
|
||||||
import net.minecraft.data.DataGenerator;
|
import net.minecraft.data.DataGenerator;
|
||||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
import net.minecraftforge.client.model.generators.ExistingFileHelper;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
|
import net.minecraftforge.fml.event.lifecycle.GatherDataEvent;
|
||||||
|
|
|
@ -3,7 +3,6 @@ package thetadev.constructionwand.data;
|
||||||
import net.minecraft.data.*;
|
import net.minecraft.data.*;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.item.crafting.SpecialRecipeSerializer;
|
import net.minecraft.item.crafting.SpecialRecipeSerializer;
|
||||||
import net.minecraft.tags.ItemTags;
|
|
||||||
import net.minecraft.util.IItemProvider;
|
import net.minecraft.util.IItemProvider;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
@ -23,7 +22,7 @@ public class RecipeGenerator extends RecipeProvider
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerRecipes(@Nonnull Consumer<IFinishedRecipe> consumer) {
|
protected void registerRecipes(@Nonnull Consumer<IFinishedRecipe> consumer) {
|
||||||
wandRecipe(consumer, ModItems.WAND_STONE, Inp.fromTag(ItemTags.field_232909_aa_)); //stone_tool_materials
|
wandRecipe(consumer, ModItems.WAND_STONE, Inp.fromTag(Tags.Items.COBBLESTONE));
|
||||||
wandRecipe(consumer, ModItems.WAND_IRON, Inp.fromTag(Tags.Items.INGOTS_IRON));
|
wandRecipe(consumer, ModItems.WAND_IRON, Inp.fromTag(Tags.Items.INGOTS_IRON));
|
||||||
wandRecipe(consumer, ModItems.WAND_DIAMOND, Inp.fromTag(Tags.Items.GEMS_DIAMOND));
|
wandRecipe(consumer, ModItems.WAND_DIAMOND, Inp.fromTag(Tags.Items.GEMS_DIAMOND));
|
||||||
wandRecipe(consumer, ModItems.WAND_INFINITY, Inp.fromTag(Tags.Items.NETHER_STARS));
|
wandRecipe(consumer, ModItems.WAND_INFINITY, Inp.fromTag(Tags.Items.NETHER_STARS));
|
||||||
|
|
|
@ -4,7 +4,6 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.color.ItemColors;
|
import net.minecraft.client.renderer.color.ItemColors;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemModelsProperties;
|
|
||||||
import net.minecraft.item.ItemTier;
|
import net.minecraft.item.ItemTier;
|
||||||
import net.minecraft.item.crafting.IRecipeSerializer;
|
import net.minecraft.item.crafting.IRecipeSerializer;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
|
@ -74,17 +73,6 @@ public class ModItems
|
||||||
register(r, "wand_upgrade", RecipeWandUpgrade.SERIALIZER);
|
register(r, "wand_upgrade", RecipeWandUpgrade.SERIALIZER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
public static void registerModelProperties() {
|
|
||||||
for(Item item : WANDS) {
|
|
||||||
ItemModelsProperties.func_239418_a_(
|
|
||||||
item, ConstructionWand.loc("using_core"),
|
|
||||||
(stack, world, entity) -> entity == null || !(stack.getItem() instanceof ItemWand) ? 0 :
|
|
||||||
new WandOptions(stack).cores.get().getColor() > -1 ? 1 : 0
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public static void registerItemColors() {
|
public static void registerItemColors() {
|
||||||
ItemColors colors = Minecraft.getInstance().getItemColors();
|
ItemColors colors = Minecraft.getInstance().getItemColors();
|
||||||
|
|
|
@ -24,8 +24,8 @@ public abstract class ItemCore extends ItemBase implements IWandCore
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void addInformation(@Nonnull ItemStack itemstack, World worldIn, @Nonnull List<ITextComponent> lines, @Nonnull ITooltipFlag extraInfo) {
|
public void addInformation(@Nonnull ItemStack itemstack, World worldIn, @Nonnull List<ITextComponent> lines, @Nonnull ITooltipFlag extraInfo) {
|
||||||
lines.add(new TranslationTextComponent(ConstructionWand.MODID + ".option.cores." + getRegistryName().toString() + ".desc")
|
lines.add(new TranslationTextComponent(ConstructionWand.MODID + ".option.cores." + getRegistryName().toString() + ".desc")
|
||||||
.mergeStyle(TextFormatting.GRAY));
|
.applyTextStyle(TextFormatting.GRAY));
|
||||||
lines.add(new TranslationTextComponent(ConstructionWand.MODID + ".tooltip.core_tip")
|
lines.add(new TranslationTextComponent(ConstructionWand.MODID + ".tooltip.core_tip")
|
||||||
.mergeStyle(TextFormatting.AQUA));
|
.applyTextStyle(TextFormatting.AQUA));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.item.ItemUseContext;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.ActionResultType;
|
import net.minecraft.util.ActionResultType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
@ -36,6 +37,9 @@ public abstract class ItemWand extends ItemBase implements ICustomItemModel
|
||||||
{
|
{
|
||||||
public ItemWand(String name, Properties properties) {
|
public ItemWand(String name, Properties properties) {
|
||||||
super(name, properties);
|
super(name, properties);
|
||||||
|
addPropertyOverride(new ResourceLocation(ConstructionWand.MODID, "using_core"),
|
||||||
|
(stack, world, entity) -> entity == null || !(stack.getItem() instanceof ItemWand) ? 0 :
|
||||||
|
new WandOptions(stack).cores.get().getColor() > -1 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -106,13 +110,13 @@ public abstract class ItemWand extends ItemBase implements ICustomItemModel
|
||||||
if(Screen.hasShiftDown()) {
|
if(Screen.hasShiftDown()) {
|
||||||
for(int i = 1; i < options.allOptions.length; i++) {
|
for(int i = 1; i < options.allOptions.length; i++) {
|
||||||
IOption<?> opt = options.allOptions[i];
|
IOption<?> opt = options.allOptions[i];
|
||||||
lines.add(new TranslationTextComponent(opt.getKeyTranslation()).mergeStyle(TextFormatting.AQUA)
|
lines.add(new TranslationTextComponent(opt.getKeyTranslation()).applyTextStyle(TextFormatting.AQUA)
|
||||||
.append(new TranslationTextComponent(opt.getValueTranslation()).mergeStyle(TextFormatting.GRAY))
|
.appendSibling(new TranslationTextComponent(opt.getValueTranslation()).applyTextStyle(TextFormatting.GRAY))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if(!options.cores.getUpgrades().isEmpty()) {
|
if(!options.cores.getUpgrades().isEmpty()) {
|
||||||
lines.add(new StringTextComponent(""));
|
lines.add(new StringTextComponent(""));
|
||||||
lines.add(new TranslationTextComponent(langTooltip + "cores").mergeStyle(TextFormatting.GRAY));
|
lines.add(new TranslationTextComponent(langTooltip + "cores").applyTextStyle(TextFormatting.GRAY));
|
||||||
|
|
||||||
for(IWandCore core : options.cores.getUpgrades()) {
|
for(IWandCore core : options.cores.getUpgrades()) {
|
||||||
lines.add(new TranslationTextComponent(options.cores.getKeyTranslation() + "." + core.getRegistryName().toString()));
|
lines.add(new TranslationTextComponent(options.cores.getKeyTranslation() + "." + core.getRegistryName().toString()));
|
||||||
|
@ -122,19 +126,19 @@ public abstract class ItemWand extends ItemBase implements ICustomItemModel
|
||||||
// Default tooltip: show block limit + active wand core
|
// Default tooltip: show block limit + active wand core
|
||||||
else {
|
else {
|
||||||
IOption<?> opt = options.allOptions[0];
|
IOption<?> opt = options.allOptions[0];
|
||||||
lines.add(new TranslationTextComponent(langTooltip + "blocks", limit).mergeStyle(TextFormatting.GRAY));
|
lines.add(new TranslationTextComponent(langTooltip + "blocks", limit).applyTextStyle(TextFormatting.GRAY));
|
||||||
lines.add(new TranslationTextComponent(opt.getKeyTranslation()).mergeStyle(TextFormatting.AQUA)
|
lines.add(new TranslationTextComponent(opt.getKeyTranslation()).applyTextStyle(TextFormatting.AQUA)
|
||||||
.append(new TranslationTextComponent(opt.getValueTranslation()).mergeStyle(TextFormatting.WHITE)));
|
.appendSibling(new TranslationTextComponent(opt.getValueTranslation()).applyTextStyle(TextFormatting.WHITE)));
|
||||||
lines.add(new TranslationTextComponent(langTooltip + "shift").mergeStyle(TextFormatting.AQUA));
|
lines.add(new TranslationTextComponent(langTooltip + "shift").applyTextStyle(TextFormatting.AQUA));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void optionMessage(PlayerEntity player, IOption<?> option) {
|
public static void optionMessage(PlayerEntity player, IOption<?> option) {
|
||||||
player.sendStatusMessage(
|
player.sendStatusMessage(
|
||||||
new TranslationTextComponent(option.getKeyTranslation()).mergeStyle(TextFormatting.AQUA)
|
new TranslationTextComponent(option.getKeyTranslation()).applyTextStyle(TextFormatting.AQUA)
|
||||||
.append(new TranslationTextComponent(option.getValueTranslation()).mergeStyle(TextFormatting.WHITE))
|
.appendSibling(new TranslationTextComponent(option.getValueTranslation()).applyTextStyle(TextFormatting.WHITE))
|
||||||
.append(new StringTextComponent(" - ").mergeStyle(TextFormatting.GRAY))
|
.appendSibling(new StringTextComponent(" - ").applyTextStyle(TextFormatting.GRAY))
|
||||||
.append(new TranslationTextComponent(option.getDescTranslation()).mergeStyle(TextFormatting.WHITE))
|
.appendSibling(new TranslationTextComponent(option.getDescTranslation()).applyTextStyle(TextFormatting.WHITE))
|
||||||
, true);
|
, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,6 @@ package thetadev.constructionwand.items.wand;
|
||||||
public class ItemWandInfinity extends ItemWand
|
public class ItemWandInfinity extends ItemWand
|
||||||
{
|
{
|
||||||
public ItemWandInfinity(String name, Properties properties) {
|
public ItemWandInfinity(String name, Properties properties) {
|
||||||
super(name, properties.maxStackSize(1).isBurnable());
|
super(name, properties.maxStackSize(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import thetadev.constructionwand.basics.WandUtil;
|
import thetadev.constructionwand.basics.WandUtil;
|
||||||
|
|
||||||
|
@ -18,10 +18,10 @@ public class WandItemUseContext extends BlockItemUseContext
|
||||||
new BlockRayTraceResult(getBlockHitVec(rayTraceResult, pos), rayTraceResult.getFace(), pos, false));
|
new BlockRayTraceResult(getBlockHitVec(rayTraceResult, pos), rayTraceResult.getFace(), pos, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Vector3d getBlockHitVec(BlockRayTraceResult rayTraceResult, BlockPos pos) {
|
private static Vec3d getBlockHitVec(BlockRayTraceResult rayTraceResult, BlockPos pos) {
|
||||||
Vector3d hitVec = rayTraceResult.getHitVec(); // Absolute coords of hit target
|
Vec3d hitVec = rayTraceResult.getHitVec(); // Absolute coords of hit target
|
||||||
|
|
||||||
Vector3d blockDelta = WandUtil.blockPosVec(rayTraceResult.getPos()).subtract(WandUtil.blockPosVec(pos)); // Vector between start and current block
|
Vec3d blockDelta = WandUtil.blockPosVec(rayTraceResult.getPos()).subtract(WandUtil.blockPosVec(pos)); // Vector between start and current block
|
||||||
|
|
||||||
return blockDelta.add(hitVec); // Absolute coords of current block hit target
|
return blockDelta.add(hitVec); // Absolute coords of current block hit target
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import thetadev.constructionwand.api.IWandAction;
|
import thetadev.constructionwand.api.IWandAction;
|
||||||
import thetadev.constructionwand.api.IWandSupplier;
|
import thetadev.constructionwand.api.IWandSupplier;
|
||||||
|
@ -57,9 +57,9 @@ public class ActionAngel implements IWandAction
|
||||||
|
|
||||||
if(!player.isCreative() && !ConfigServer.ANGEL_FALLING.get() && player.fallDistance > 10) return placeSnapshots;
|
if(!player.isCreative() && !ConfigServer.ANGEL_FALLING.get() && player.fallDistance > 10) return placeSnapshots;
|
||||||
|
|
||||||
Vector3d playerVec = WandUtil.entityPositionVec(player);
|
Vec3d playerVec = WandUtil.entityPositionVec(player);
|
||||||
Vector3d lookVec = player.getLookVec().mul(2, 2, 2);
|
Vec3d lookVec = player.getLookVec().mul(2, 2, 2);
|
||||||
Vector3d placeVec = playerVec.add(lookVec);
|
Vec3d placeVec = playerVec.add(lookVec);
|
||||||
|
|
||||||
BlockPos currentPos = new BlockPos(placeVec);
|
BlockPos currentPos = new BlockPos(placeVec);
|
||||||
|
|
||||||
|
|
|
@ -119,13 +119,13 @@ public class PlaceSnapshot implements ISnapshot
|
||||||
for(Property property : new Property[]{
|
for(Property property : new Property[]{
|
||||||
BlockStateProperties.HORIZONTAL_FACING, BlockStateProperties.FACING, BlockStateProperties.FACING_EXCEPT_UP,
|
BlockStateProperties.HORIZONTAL_FACING, BlockStateProperties.FACING, BlockStateProperties.FACING_EXCEPT_UP,
|
||||||
BlockStateProperties.ROTATION_0_15, BlockStateProperties.AXIS, BlockStateProperties.HALF, BlockStateProperties.STAIRS_SHAPE}) {
|
BlockStateProperties.ROTATION_0_15, BlockStateProperties.AXIS, BlockStateProperties.HALF, BlockStateProperties.STAIRS_SHAPE}) {
|
||||||
if(supportingBlock.hasProperty(property) && blockState.hasProperty(property)) {
|
if(supportingBlock.has(property) && blockState.has(property)) {
|
||||||
blockState = blockState.with(property, supportingBlock.get(property));
|
blockState = blockState.with(property, supportingBlock.get(property));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dont dupe double slabs
|
// Dont dupe double slabs
|
||||||
if(supportingBlock.hasProperty(BlockStateProperties.SLAB_TYPE) && blockState.hasProperty(BlockStateProperties.SLAB_TYPE)) {
|
if(supportingBlock.has(BlockStateProperties.SLAB_TYPE) && blockState.has(BlockStateProperties.SLAB_TYPE)) {
|
||||||
SlabType slabType = supportingBlock.get(BlockStateProperties.SLAB_TYPE);
|
SlabType slabType = supportingBlock.get(BlockStateProperties.SLAB_TYPE);
|
||||||
if(slabType != SlabType.DOUBLE) blockState = blockState.with(BlockStateProperties.SLAB_TYPE, slabType);
|
if(slabType != SlabType.DOUBLE) blockState = blockState.with(BlockStateProperties.SLAB_TYPE, slabType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
modLoader="javafml"
|
modLoader="javafml"
|
||||||
loaderVersion="[33,)"
|
|
||||||
license="MIT License"
|
license="MIT License"
|
||||||
|
loaderVersion="[31,)"
|
||||||
[[mods]]
|
[[mods]]
|
||||||
modId="constructionwand"
|
modId="constructionwand"
|
||||||
version="${file.jarVersion}"
|
version="${file.jarVersion}"
|
||||||
|
@ -20,12 +20,12 @@ This is my first minecraft mod. May the odds be ever in your favor.
|
||||||
[[dependencies.constructionwand]]
|
[[dependencies.constructionwand]]
|
||||||
modId="forge"
|
modId="forge"
|
||||||
mandatory=true
|
mandatory=true
|
||||||
versionRange="[33,)"
|
versionRange="[31,)"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="BOTH"
|
side="BOTH"
|
||||||
[[dependencies.constructionwand]]
|
[[dependencies.constructionwand]]
|
||||||
modId="minecraft"
|
modId="minecraft"
|
||||||
mandatory=true
|
mandatory=true
|
||||||
versionRange="[1.16.2, 1.16.5]"
|
versionRange="[1.15.2]"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="BOTH"
|
side="BOTH"
|
||||||
|
|
Loading…
Add table
Reference in a new issue