added all features of the newest 1.18.2

This commit is contained in:
Magistu 2024-02-03 22:45:49 +03:00 committed by Magistu
parent 46daaa5d56
commit b0d6185625
93 changed files with 12679 additions and 1207 deletions

2
.gitignore vendored
View File

@ -19,7 +19,7 @@ build
# other
eclipse
run
run*
# Files from Forge MDK
forge*changelog.txt

View File

@ -4,9 +4,9 @@ plugins {
id 'net.minecraftforge.gradle' version '5.1.+'
}
version = '1.0'
version = rootProject.mod_version
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'modid'
archivesBaseName = rootProject.archives_base_name
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
@ -164,6 +164,14 @@ dependencies {
// http://www.gradle.org/docs/current/userguide/dependency_management.html
}
processResources {
inputs.property "version", project.version
filesMatching("META-INF/mods.toml") {
expand "version": project.version
}
}
// Example for how to get properties into the manifest for reading at runtime.
jar {
manifest {

View File

@ -3,5 +3,8 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
mod_version=1.17
archives_base_name=[1.19.2]-Siege-Machines
mc_version=1.19.2
jei_version=11.5.0.297

View File

@ -4,9 +4,10 @@ import net.minecraftforge.fml.event.lifecycle.*;
import ru.magistu.siegemachines.block.ModBlocks;
import ru.magistu.siegemachines.client.ClientProxy;
import ru.magistu.siegemachines.client.SoundTypes;
import ru.magistu.siegemachines.data.recipes.ModRecipes;
import ru.magistu.siegemachines.config.SpecsConfig;
import ru.magistu.siegemachines.item.recipes.ModRecipes;
import ru.magistu.siegemachines.entity.EntityTypes;
import ru.magistu.siegemachines.gui.ModMenuTypes;
import ru.magistu.siegemachines.client.gui.ModMenuTypes;
import ru.magistu.siegemachines.item.ModItems;
import ru.magistu.siegemachines.network.PacketHandler;
import ru.magistu.siegemachines.proxy.IProxy;
@ -52,6 +53,7 @@ public class SiegeMachines {
ModBlocks.register(eventBus);
ModItems.register(eventBus);
ModRecipes.register(eventBus);
SpecsConfig.register();
PacketHandler.init();

View File

@ -14,9 +14,8 @@ import net.minecraft.world.level.block.CraftingTableBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.network.NetworkHooks;
import net.minecraftforge.registries.ForgeRegistries;
import org.jetbrains.annotations.NotNull;
import ru.magistu.siegemachines.gui.workbench.SiegeWorkbenchContainer;
import ru.magistu.siegemachines.client.gui.workbench.SiegeWorkbenchContainer;
public class SiegeWorkbench extends CraftingTableBlock
{

View File

@ -20,9 +20,12 @@ public class ClientListener
event.registerEntityRenderer(EntityTypes.CATAPULT.get(), CatapultGeoRenderer::new);
event.registerEntityRenderer(EntityTypes.BALLISTA.get(), BallistaGeoRenderer::new);
event.registerEntityRenderer(EntityTypes.BATTERING_RAM.get(), BatteringRamGeoRenderer::new);
event.registerEntityRenderer(EntityTypes.SIEGE_LADDER.get(), SiegeLadderGeoRenderer::new);
event.registerEntityRenderer(EntityTypes.CANNONBALL.get(), ThrownItemRenderer::new);
event.registerEntityRenderer(EntityTypes.STONE.get(), ThrownItemRenderer::new);
event.registerEntityRenderer(EntityTypes.GIANT_ARROW.get(), GiantArrowRenderer::new);
event.registerEntityRenderer(EntityTypes.SEAT.get(), SeatRenderer::new);
}
}

View File

@ -1,8 +1,8 @@
package ru.magistu.siegemachines.client;
import ru.magistu.siegemachines.gui.ModMenuTypes;
import ru.magistu.siegemachines.gui.workbench.SiegeWorkbenchScreen;
import ru.magistu.siegemachines.gui.machine.MachineInventoryScreen;
import ru.magistu.siegemachines.client.gui.ModMenuTypes;
import ru.magistu.siegemachines.client.gui.workbench.SiegeWorkbenchScreen;
import ru.magistu.siegemachines.client.gui.machine.MachineInventoryScreen;
import ru.magistu.siegemachines.proxy.IProxy;
import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraftforge.eventbus.api.IEventBus;

View File

@ -2,9 +2,18 @@ package ru.magistu.siegemachines.client;
import ru.magistu.siegemachines.SiegeMachines;
import net.minecraft.client.KeyMapping;
import ru.magistu.siegemachines.entity.machine.MachineType;
public class KeyBindings
{
public static KeyMapping MACHINE_USE = new KeyMapping(SiegeMachines.ID + ".machine_use", 70, SiegeMachines.ID + ".category");
public static KeyMapping LADDER_CLIMB = new KeyMapping(SiegeMachines.ID + ".ladder_climb", 32, SiegeMachines.ID + ".category");
public static KeyMapping MACHINE_INVENTORY = new KeyMapping(SiegeMachines.ID + ".machine_inventory", 73, SiegeMachines.ID + ".category");
public static KeyMapping getUseKey(MachineType type)
{
if (type == MachineType.SIEGE_LADDER)
return LADDER_CLIMB;
return MACHINE_USE;
}
}

View File

@ -0,0 +1,28 @@
package ru.magistu.siegemachines.client.gui;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.client.gui.machine.MachineContainer;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraftforge.common.extensions.IForgeMenuType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.network.IContainerFactory;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import ru.magistu.siegemachines.client.gui.workbench.SiegeWorkbenchContainer;
public class ModMenuTypes {
public static final DeferredRegister<MenuType<?>> MENUS = DeferredRegister.create(ForgeRegistries.MENU_TYPES, SiegeMachines.ID);
public static final RegistryObject<MenuType<MachineContainer>> MACHINE_CONTAINER = MENUS.register("machine", () -> IForgeMenuType.create(MachineContainer::new));
public static final RegistryObject<MenuType<SiegeWorkbenchContainer>> SIEGE_WORKBENCH_CONTAINER = registerMenuType(SiegeWorkbenchContainer::new, "siege_workbench");
private static <T extends AbstractContainerMenu> RegistryObject<MenuType<T>> registerMenuType(IContainerFactory<T> factory, String name) {
return MENUS.register(name, () -> IForgeMenuType.create(factory));
}
public static void register(IEventBus eventBus) {
MENUS.register(eventBus);
}
}

View File

@ -0,0 +1,136 @@
package ru.magistu.siegemachines.client.gui.machine;
import ru.magistu.siegemachines.entity.machine.Machine;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import org.jetbrains.annotations.NotNull;
import ru.magistu.siegemachines.client.gui.ModMenuTypes;
import java.util.Objects;
public class MachineContainer extends AbstractContainerMenu
{
private Player player;
private Machine machine;
int x, y, z;
private IItemHandler internal;
private boolean bound = false;
public MachineContainer(final int id, final Inventory inv, final Machine machine)
{
super(ModMenuTypes.MACHINE_CONTAINER.get(), id);
if (machine == null)
{
return;
}
this.machine = machine;
for (int row = 0; row < 3; row++)
{
for (int col = 0; col < 9; col++)
{
this.addSlot(new Slot(inv, col + row * 9 + 9, 8 + col * 18, 166 - (4 - row) * 18 - 10));
}
}
for (int col = 0; col < 9; col++)
{
this.addSlot(new Slot(inv, col, 8 + col * 18, 142));
}
for (int row = 0; row < 1; row++)
{
for (int col = 0; col < 9; col++)
{
this.addSlot(new Slot(machine.inventory, col + row * 9, 8 + col * 18, 18 + row * 18));
}
}
}
public MachineContainer(final int id, final Inventory inv, final FriendlyByteBuf data)
{
this(id, inv, getMachine(inv));
}
private static Machine getMachine(final Inventory inv)
{
Objects.requireNonNull(inv, "Player Inventory Cannot Be Null.");
Player player = inv.player;
Entity entity;
if (player.isPassenger())
{
entity = player.getVehicle();
if (entity instanceof Machine)
{
return (Machine) player.getVehicle();
}
}
throw new IllegalStateException("Entity Is Not Correct.");
}
@Override
public boolean stillValid(Player player)
{
return machine.inventory.stillValid(player);
}
@Override
public @NotNull ItemStack quickMoveStack(@NotNull Player player, int index)
{
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = this.slots.get(index);
if (slot != null && slot.hasItem())
{
ItemStack itemstack1 = slot.getItem();
itemstack = itemstack1.copy();
if (index < 9)
{
if (!this.moveItemStackTo(itemstack1, 9, this.slots.size(), true))
{
return ItemStack.EMPTY;
}
slot.onQuickCraft(itemstack1, itemstack);
}
else if (!this.moveItemStackTo(itemstack1, 0, 9, false))
{
if (index < 9 + 27)
{
if (!this.moveItemStackTo(itemstack1, 9 + 27, this.slots.size(), true))
{
return ItemStack.EMPTY;
}
}
else
{
if (!this.moveItemStackTo(itemstack1, 9, 9 + 27, false))
{
return ItemStack.EMPTY;
}
}
return ItemStack.EMPTY;
}
if (itemstack1.getCount() == 0)
{
slot.set(ItemStack.EMPTY);
}
else
{
slot.setChanged();
}
if (itemstack1.getCount() == itemstack.getCount())
{
return ItemStack.EMPTY;
}
slot.onTake(player, itemstack1);
}
return itemstack;
}
}

View File

@ -0,0 +1,71 @@
package ru.magistu.siegemachines.client.gui.machine;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import ru.magistu.siegemachines.SiegeMachines;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.api.distmarker.Dist;
import org.jetbrains.annotations.NotNull;
@OnlyIn(Dist.CLIENT)
public class MachineInventoryScreen extends AbstractContainerScreen<MachineContainer>
{
private static final ResourceLocation DISPLAY_CASE_GUI = new ResourceLocation(SiegeMachines.ID,
"textures/gui/machine_inventory.png");
public MachineInventoryScreen(MachineContainer screenContainer, Inventory inv, Component titleIn)
{
super(screenContainer, inv, titleIn);
this.leftPos = 0;
this.topPos = 0;
this.imageWidth = 176;
this.imageHeight = 166;
}
@Override
public void render(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks)
{
this.renderBackground(matrixStack);
super.render(matrixStack, mouseX, mouseY, partialTicks);
this.renderTooltip(matrixStack, mouseX, mouseY);
}
@Override
protected void renderTooltip(@NotNull PoseStack matrixStack, int x, int y)
{
if (this.minecraft.player.getInventory().getSelected().isEmpty() && this.hoveredSlot != null && this.hoveredSlot.hasItem())
{
this.renderTooltip(matrixStack, this.hoveredSlot.getItem(), x, y);
}
}
@Override
protected void renderBg(@NotNull PoseStack matrixStack, float partialTicks, int mouseX, int mouseY)
{
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, DISPLAY_CASE_GUI);
int x = (this.width - this.imageWidth) / 2;
int y = (this.height - this.imageHeight) / 2;
this.blit(matrixStack, x, y, 0, 0, this.imageWidth, this.imageHeight);
}
@Override
public boolean keyPressed(int key, int b, int c)
{
assert this.minecraft != null;
if (key == 256)
{
assert this.minecraft.player != null;
this.minecraft.player.closeContainer();
return true;
}
return super.keyPressed(key, b, c);
}
}

View File

@ -0,0 +1,31 @@
package ru.magistu.siegemachines.client.gui.machine.crosshair;
import java.util.Arrays;
import java.util.List;
public class AlignmentHelper
{
public static final List<String> validAlignmentValues = Arrays.asList(new String[] { "top_left", "top_center", "top_right", "center_left", "center", "center_right", "bottom_left", "bottom_center", "bottom_right" });
public enum Alignment
{
TOP_LEFT,
TOP_CENTER,
TOP_RIGHT,
CENTER_LEFT,
CENTER,
CENTER_RIGHT,
BOTTOM_LEFT,
BOTTOM_CENTER,
BOTTOM_RIGHT;
public static Alignment fromString(String align) {
int idx = AlignmentHelper.validAlignmentValues.indexOf(align);
if (idx != -1) {
return values()[idx];
}
return CENTER;
}
}
}

View File

@ -0,0 +1,25 @@
package ru.magistu.siegemachines.client.gui.machine.crosshair;
import com.mojang.blaze3d.vertex.PoseStack;
import ru.magistu.siegemachines.SiegeMachines;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public abstract class Crosshair extends HudElement
{
protected static final ResourceLocation CROSSHAIR_TEXTURES = new ResourceLocation(SiegeMachines.ID, "textures/gui/crosshairs.png");
public Crosshair(int width, int height)
{
super(width, height);
}
public final void render(PoseStack matrixstack, float partialticks) {}
public abstract void render(PoseStack matrixstack, float ticks, Minecraft mc, Player player);
}

View File

@ -0,0 +1,73 @@
package ru.magistu.siegemachines.client.gui.machine.crosshair;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public abstract class HudElement
{
protected int width;
protected int height;
public int getAlignedX(AlignmentHelper.Alignment align, int offset)
{
switch (align)
{
case TOP_LEFT:
case CENTER_LEFT:
case BOTTOM_LEFT:
return 5 + offset;
case TOP_CENTER:
case CENTER:
case BOTTOM_CENTER:
return Minecraft.getInstance().getWindow().getGuiScaledWidth() / 2 - this.width / 2 + offset;
case TOP_RIGHT:
case CENTER_RIGHT:
case BOTTOM_RIGHT:
return Minecraft.getInstance().getWindow().getGuiScaledWidth() - this.width - 5 + offset;
}
return 0;
}
public int getAlignedY(AlignmentHelper.Alignment align, int offset)
{
switch (align)
{
case TOP_LEFT:
case TOP_CENTER:
case TOP_RIGHT:
return 5 + offset;
case CENTER_LEFT:
case CENTER:
case CENTER_RIGHT:
return Minecraft.getInstance().getWindow().getGuiScaledHeight() / 2 - this.height / 2 + 16 + offset;
case BOTTOM_CENTER:
return Minecraft.getInstance().getWindow().getGuiScaledHeight() - this.height - 65 + offset;
case BOTTOM_LEFT:
case BOTTOM_RIGHT:
return Minecraft.getInstance().getWindow().getGuiScaledHeight() - this.height - 5 + offset;
}
return 0;
}
public HudElement(int elementWidth, int elementHeight)
{
this.width = elementWidth;
this.height = elementHeight;
}
public int getWidth()
{
return this.width;
}
public int getHeight()
{
return this.height;
}
public abstract void render(PoseStack paramMatrixStack, float paramFloat);
}

View File

@ -0,0 +1,68 @@
package ru.magistu.siegemachines.client.gui.machine.crosshair;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import ru.magistu.siegemachines.entity.machine.Machine;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class ReloadingCrosshair extends Crosshair
{
//public static ResourceLocation TYPE = new ResourceLocation(SiegeMachines.ID, "siege_machine");
public int x;
public int y;
public ReloadingCrosshair()
{
super(9, 9);
this.x = Minecraft.getInstance().getWindow().getGuiScaledWidth() / 2;
this.y = Minecraft.getInstance().getWindow().getGuiScaledHeight() / 2;
}
public void render(PoseStack matrixstack, float ticks, Minecraft mc, Player player)
{
RenderSystem.assertOnRenderThread();
if (!player.isPassenger())
{
return;
}
Entity entity = player.getVehicle();
if (entity instanceof Machine)
{
Machine machine = (Machine) entity;
int width = 11;
int height = 11;
int imagex = 0;
int imagey = 0;
int originx = (mc.getWindow().getGuiScaledWidth() - width) / 2;
int originy = (mc.getWindow().getGuiScaledHeight() - height) / 2;
int animationsize = 23;
if (machine.useticks > 0)
{
imagey = height;
}
else if (machine.delayticks > 0)
{
int number = (int) (((double) animationsize) * ((double) (machine.type.specs.delaytime.get() - machine.delayticks) / (double) machine.type.specs.delaytime.get()));
imagex = width;
imagey = height * number;
}
RenderSystem.applyModelViewMatrix();
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, CROSSHAIR_TEXTURES);
mc.gui.blit(matrixstack, originx, originy, imagex, imagey, width, height);
RenderSystem.backupProjectionMatrix();
}
}
}

View File

@ -0,0 +1,196 @@
package ru.magistu.siegemachines.client.gui.workbench;
import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.StackedContents;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.Container;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.*;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.level.Level;
import ru.magistu.siegemachines.block.ModBlocks;
import ru.magistu.siegemachines.item.recipes.ModRecipes;
import ru.magistu.siegemachines.item.recipes.SiegeWorkbenchRecipe;
import ru.magistu.siegemachines.client.gui.ModMenuTypes;
import java.util.Optional;
public class SiegeWorkbenchContainer extends AbstractContainerMenu
{
private final CraftingContainer craftSlots = new CraftingContainer(this, 3, 3);
private final ResultContainer resultSlots = new ResultContainer();
private final ContainerLevelAccess access;
private final Player player;
public SiegeWorkbenchContainer(int id, Inventory inventory, FriendlyByteBuf buffer)
{
this(id, inventory, ContainerLevelAccess.NULL);
}
public SiegeWorkbenchContainer(int id, Inventory inventory, ContainerLevelAccess access)
{
super(ModMenuTypes.SIEGE_WORKBENCH_CONTAINER.get(), id);
this.access = access;
this.player = inventory.player;
this.addSlot(new SiegeWorkbenchResultSlot(inventory.player, this.craftSlots, this.resultSlots, 0, 124, 35));
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < 3; ++j)
{
this.addSlot(new Slot(this.craftSlots, j + i * 3, 30 + j * 18, 17 + i * 18));
}
}
for (int k = 0; k < 3; ++k)
{
for (int i1 = 0; i1 < 9; ++i1)
{
this.addSlot(new Slot(inventory, i1 + k * 9 + 9, 8 + i1 * 18, 84 + k * 18));
}
}
for (int l = 0; l < 9; ++l)
{
this.addSlot(new Slot(inventory, l, 8 + l * 18, 142));
}
}
// to create resulting item
protected static void slotChangedCraftingGrid(AbstractContainerMenu menu, Level level, Player player, CraftingContainer craftingcontainer, ResultContainer resultcontainer) {
if (!level.isClientSide) {
ServerPlayer serverplayer = (ServerPlayer)player;
ItemStack itemstack = ItemStack.EMPTY;
Optional<SiegeWorkbenchRecipe> optional = level.getServer().getRecipeManager().getRecipeFor(ModRecipes.SIEGE_WORKBENCH_RECIPE, craftingcontainer, level);
if (optional.isPresent()) {
SiegeWorkbenchRecipe craftingrecipe = optional.get();
if (resultcontainer.setRecipeUsed(level, serverplayer, craftingrecipe)) {
itemstack = craftingrecipe.assemble(craftingcontainer);
}
}
resultcontainer.setItem(0, itemstack);
//menu.setRemoteSlot(0, itemstack);
serverplayer.connection.send(new ClientboundContainerSetSlotPacket(menu.containerId, menu.incrementStateId(), 0, itemstack));
}
}
@Override
public void slotsChanged(Container inventory) {
this.access.execute((level, blockpos) -> slotChangedCraftingGrid(this, level, this.player, this.craftSlots, this.resultSlots));
}
public void fillCraftSlotsStackedContents(StackedContents itemhelper) {
this.craftSlots.fillStackedContents(itemhelper);
}
public void clearCraftingContent() {
this.craftSlots.clearContent();
this.resultSlots.clearContent();
}
public boolean recipeMatches(Recipe<? super CraftingContainer> recipe) {
return recipe.matches(this.craftSlots, this.player.level);
}
/**
* Called when the container is closed.
*/
public void removed(Player player) {
super.removed(player);
this.access.execute((p_39371_, p_39372_) -> {
this.clearContainer(player, this.craftSlots);
});
}
/**
* Determines whether supplied player can use this container
*/
public boolean stillValid(Player player) {
return stillValid(this.access, player, ModBlocks.SIEGE_WORKBENCH.get());
}
/**
* Handle when the stack in slot {@code index} is shift-clicked. Normally this moves the stack between the player
* inventory and the other inventory(s).
*/
public ItemStack quickMoveStack(Player player, int index) {
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = this.slots.get(index);
if (slot != null && slot.hasItem()) {
ItemStack itemstack1 = slot.getItem();
itemstack = itemstack1.copy();
if (index == 0) {
this.access.execute((p_39378_, p_39379_) -> {
itemstack1.getItem().onCraftedBy(itemstack1, p_39378_, player);
});
if (!this.moveItemStackTo(itemstack1, 10, 46, true)) {
return ItemStack.EMPTY;
}
slot.onQuickCraft(itemstack1, itemstack);
} else if (index >= 10 && index < 46) {
if (!this.moveItemStackTo(itemstack1, 1, 10, false)) {
if (index < 37) {
if (!this.moveItemStackTo(itemstack1, 37, 46, false)) {
return ItemStack.EMPTY;
}
} else if (!this.moveItemStackTo(itemstack1, 10, 37, false)) {
return ItemStack.EMPTY;
}
}
} else if (!this.moveItemStackTo(itemstack1, 10, 46, false)) {
return ItemStack.EMPTY;
}
if (itemstack1.isEmpty()) {
slot.set(ItemStack.EMPTY);
} else {
slot.setChanged();
}
if (itemstack1.getCount() == itemstack.getCount()) {
return ItemStack.EMPTY;
}
slot.onTake(player, itemstack1);
if (index == 0) {
player.drop(itemstack1, false);
}
}
return itemstack;
}
/**
* Called to determine if the current slot is valid for the stack merging (double-click) code. The stack passed in is
* null for the initial slot that was double-clicked.
*/
public boolean canTakeItemForPickAll(ItemStack stack, Slot slot) {
return slot.container != this.resultSlots && super.canTakeItemForPickAll(stack, slot);
}
public int getResultSlotIndex() {
return 0;
}
public int getGridWidth() {
return this.craftSlots.getWidth();
}
public int getGridHeight() {
return this.craftSlots.getHeight();
}
public int getSize() {
return 10;
}
public boolean shouldMoveToInventory(int p_150553_) {
return p_150553_ != this.getResultSlotIndex();
}
}

View File

@ -0,0 +1,97 @@
package ru.magistu.siegemachines.client.gui.workbench;
import net.minecraft.core.NonNullList;
import net.minecraft.world.Container;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.inventory.RecipeHolder;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeManager;
import ru.magistu.siegemachines.item.recipes.ModRecipes;
public class SiegeWorkbenchResultSlot extends Slot {
private final CraftingContainer craftSlots;
private final Player player;
private int removeCount;
public SiegeWorkbenchResultSlot(Player player, CraftingContainer craftingcontainer, Container container, int index, int x, int y) {
super(container, index, x, y);
this.player = player;
this.craftSlots = craftingcontainer;
}
/**
* Check if the stack is allowed to be placed in this slot, used for armor slots as well as furnace fuel.
*/
public boolean mayPlace(ItemStack stack) {
return false;
}
/**
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new stack.
*/
public ItemStack remove(int amount) {
if (this.hasItem()) {
this.removeCount += Math.min(amount, this.getItem().getCount());
}
return super.remove(amount);
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
* internal count then calls onCrafting(item).
*/
protected void onQuickCraft(ItemStack stack, int amount) {
this.removeCount += amount;
this.checkTakeAchievements(stack);
}
protected void onSwapCraft(int pNumItemsCrafted) {
this.removeCount += pNumItemsCrafted;
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
*/
protected void checkTakeAchievements(ItemStack stack) {
if (this.removeCount > 0) {
stack.onCraftedBy(this.player.level, this.player, this.removeCount);
net.minecraftforge.event.ForgeEventFactory.firePlayerCraftingEvent(this.player, stack, this.craftSlots);
}
if (this.container instanceof RecipeHolder) {
((RecipeHolder)this.container).awardUsedRecipes(this.player);
}
this.removeCount = 0;
}
public void onTake(Player player, ItemStack stack) {
this.checkTakeAchievements(stack);
net.minecraftforge.common.ForgeHooks.setCraftingPlayer(player);
RecipeManager manager = player.level.getRecipeManager();
NonNullList<ItemStack> nonnulllist = manager.getRemainingItemsFor(ModRecipes.SIEGE_WORKBENCH_RECIPE, craftSlots, player.level);
net.minecraftforge.common.ForgeHooks.setCraftingPlayer(null);
for (int i = 0; i < nonnulllist.size(); ++i) {
ItemStack itemstack = this.craftSlots.getItem(i);
ItemStack itemstack1 = nonnulllist.get(i);
if (!itemstack.isEmpty()) {
this.craftSlots.removeItem(i, itemstack1.getCount());
itemstack = this.craftSlots.getItem(i);
}
if (!itemstack1.isEmpty()) {
if (itemstack.isEmpty()) {
this.craftSlots.setItem(i, itemstack1);
} else if (ItemStack.isSame(itemstack, itemstack1) && ItemStack.tagMatches(itemstack, itemstack1)) {
itemstack1.grow(itemstack.getCount());
this.craftSlots.setItem(i, itemstack1);
} else if (!this.player.getInventory().add(itemstack1)) {
this.player.drop(itemstack1, false);
}
}
}
}
}

View File

@ -0,0 +1,72 @@
package ru.magistu.siegemachines.client.gui.workbench;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.NotNull;
import ru.magistu.siegemachines.SiegeMachines;
@OnlyIn(Dist.CLIENT)
public class SiegeWorkbenchScreen extends AbstractContainerScreen<SiegeWorkbenchContainer>
{
private static final ResourceLocation DISPLAY_CASE_GUI = new ResourceLocation(SiegeMachines.ID, "textures/gui/siege_workbench.png");
public SiegeWorkbenchScreen(SiegeWorkbenchContainer screenContainer, Inventory inv, Component titleIn)
{
super(screenContainer, inv, titleIn);
}
@Override
public void render(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks)
{
this.renderBackground(matrixStack);
super.render(matrixStack, mouseX, mouseY, partialTicks);
this.renderTooltip(matrixStack, mouseX, mouseY);
}
@Override
protected void renderTooltip(@NotNull PoseStack matrixStack, int x, int y)
{
if (this.minecraft.player.getInventory().getSelected().isEmpty() && this.hoveredSlot != null && this.hoveredSlot.hasItem())
{
this.renderTooltip(matrixStack, this.hoveredSlot.getItem(), x, y);
}
}
@Override
protected void init()
{
super.init();
this.titleLabelX = 29;
}
@Override
protected void renderBg(@NotNull PoseStack matrixStack, float partialTicks, int mouseX, int mouseY)
{
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, DISPLAY_CASE_GUI);
int i = this.leftPos;
int j = (this.height - this.imageHeight) / 2;
this.blit(matrixStack, i, j, 0, 0, this.imageWidth, this.imageHeight);
}
@Override
public boolean keyPressed(int key, int b, int c)
{
assert this.minecraft != null;
if (key == 256)
{
assert this.minecraft.player != null;
this.minecraft.player.closeContainer();
return true;
}
return super.keyPressed(key, b, c);
}
}

View File

@ -1,11 +0,0 @@
package ru.magistu.siegemachines.client.renderer;
import ru.magistu.siegemachines.client.renderer.model.MachineItemModel;
public class BallistaItemGeoRenderer extends MachineItemGeoRenderer
{
public BallistaItemGeoRenderer()
{
super(new MachineItemModel<>("ballista"));
}
}

View File

@ -1,11 +0,0 @@
package ru.magistu.siegemachines.client.renderer;
import ru.magistu.siegemachines.client.renderer.model.MachineItemModel;
public class BatteringRamItemGeoRenderer extends MachineItemGeoRenderer
{
public BatteringRamItemGeoRenderer()
{
super(new MachineItemModel<>("battering_ram"));
}
}

View File

@ -1,11 +0,0 @@
package ru.magistu.siegemachines.client.renderer;
import ru.magistu.siegemachines.client.renderer.model.MachineItemModel;
public class CatapultItemGeoRenderer extends MachineItemGeoRenderer
{
public CatapultItemGeoRenderer()
{
super(new MachineItemModel<>("catapult"));
}
}

View File

@ -8,6 +8,12 @@ import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;
import ru.magistu.siegemachines.entity.machine.Culverin;
import software.bernie.geckolib3.geo.render.built.GeoBone;
import software.bernie.geckolib3.geo.render.built.GeoModel;
import software.bernie.geckolib3.model.provider.GeoModelProvider;
import java.util.Optional;
public class CulverinGeoRenderer extends MachineGeoRenderer<Culverin>
{
@ -23,4 +29,17 @@ public class CulverinGeoRenderer extends MachineGeoRenderer<Culverin>
{
return RenderType.entityTranslucent(getTextureLocation(animatable));
}
@Override
public void renderEarly(Culverin animatable, PoseStack stackIn, float ticks, MultiBufferSource renderTypeBuffer, VertexConsumer vertexBuilder, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float partialTicks)
{
GeoModelProvider<Culverin> modelProvider = this.getGeoModelProvider();
GeoModel model = modelProvider.getModel(modelProvider.getModelResource(animatable));
Optional<GeoBone> bone0 = model.getBone("Barrel");
bone0.ifPresent(bone -> bone.setRotationX(-animatable.getTurretPitch() * (float) Math.PI / 180.0f));
bone0.ifPresent(bone -> bone.setRotationY(-animatable.getTurretYaw() * (float) Math.PI / 180.0f));
super.renderEarly(animatable, stackIn, ticks, renderTypeBuffer, vertexBuilder, packedLightIn, packedOverlayIn, red, green, blue, partialTicks);
}
}

View File

@ -1,11 +0,0 @@
package ru.magistu.siegemachines.client.renderer;
import ru.magistu.siegemachines.client.renderer.model.MachineItemModel;
public class CulverinItemGeoRenderer extends MachineItemGeoRenderer
{
public CulverinItemGeoRenderer()
{
super(new MachineItemModel<>("culverin"));
}
}

View File

@ -1,12 +1,13 @@
package ru.magistu.siegemachines.client.renderer;
import ru.magistu.siegemachines.client.renderer.model.MachineItemModel;
import ru.magistu.siegemachines.entity.machine.Machine;
import ru.magistu.siegemachines.item.MachineItem;
import software.bernie.geckolib3.renderers.geo.GeoItemRenderer;
public class MachineItemGeoRenderer extends GeoItemRenderer<MachineItem> {
public MachineItemGeoRenderer(MachineItemModel<MachineItem> model)
public class MachineItemGeoRenderer<T extends Machine> extends GeoItemRenderer<MachineItem<T>> {
public MachineItemGeoRenderer(MachineItemModel<MachineItem<T>> model)
{
super(model);
}
}
}

View File

@ -1,11 +0,0 @@
package ru.magistu.siegemachines.client.renderer;
import ru.magistu.siegemachines.client.renderer.model.MachineItemModel;
public class MortarItemGeoRenderer extends MachineItemGeoRenderer
{
public MortarItemGeoRenderer()
{
super(new MachineItemModel<>("mortar"));
}
}

View File

@ -0,0 +1,25 @@
package ru.magistu.siegemachines.client.renderer;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;
import ru.magistu.siegemachines.entity.machine.Seat;
public class SeatRenderer extends EntityRenderer<Seat>
{
public SeatRenderer(EntityRendererProvider.Context p_174008_)
{
super(p_174008_);
}
public boolean shouldRender(Seat seat, Frustum camera, double camx, double camy, double camz) {
return false;
}
@Override
public ResourceLocation getTextureLocation(Seat pEntity)
{
return null;
}
}

View File

@ -0,0 +1,46 @@
package ru.magistu.siegemachines.client.renderer;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.phys.AABB;
import ru.magistu.siegemachines.client.renderer.model.MachineModel;
import ru.magistu.siegemachines.entity.machine.BatteringRam;
import ru.magistu.siegemachines.entity.machine.SiegeLadder;
public class SiegeLadderGeoRenderer extends MachineGeoRenderer<SiegeLadder>
{
public SiegeLadderGeoRenderer(EntityRendererProvider.Context renderManager)
{
super(renderManager, new MachineModel<>("siege_ladder"));
}
@Override
public RenderType getRenderType(SiegeLadder animatable, float partialTicks, PoseStack stack,
MultiBufferSource renderTypeBuffer, VertexConsumer vertexBuilder, int packedLightIn,
ResourceLocation textureLocation)
{
return RenderType.entityTranslucent(getTextureLocation(animatable));
}
@Override
public boolean shouldRender(SiegeLadder animatable, Frustum camera, double camx, double camy, double camz)
{
if (!animatable.shouldRender(camx, camy, camz)) {
return false;
} else if (animatable.noCulling) {
return true;
} else {
AABB aabb = animatable.getBoundingBoxForCulling().inflate(5.0D);
if (aabb.hasNaN() || aabb.getSize() == 0.0D) {
aabb = new AABB(animatable.getX() - 2.0D, animatable.getY() - 2.0D, animatable.getZ() - 2.0D, animatable.getX() + 2.0D, animatable.getY() + 2.0D, animatable.getZ() + 2.0D);
}
return camera.isVisible(aabb);
}
}
}

View File

@ -2,7 +2,10 @@ package ru.magistu.siegemachines.client.renderer;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.world.phys.AABB;
import ru.magistu.siegemachines.client.renderer.model.MachineModel;
import ru.magistu.siegemachines.entity.machine.SiegeLadder;
import ru.magistu.siegemachines.entity.machine.Trebuchet;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
@ -43,4 +46,21 @@ public class TrebuchetGeoRenderer extends MachineGeoRenderer<Trebuchet>
super.renderEarly(animatable, stackIn, ticks, renderTypeBuffer, vertexBuilder, packedLightIn, packedOverlayIn, red, green, blue, partialTicks);
}
@Override
public boolean shouldRender(Trebuchet animatable, Frustum camera, double camx, double camy, double camz)
{
if (!animatable.shouldRender(camx, camy, camz)) {
return false;
} else if (animatable.noCulling) {
return true;
} else {
AABB aabb = animatable.getBoundingBoxForCulling().inflate(10.0D);
if (aabb.hasNaN() || aabb.getSize() == 0.0D) {
aabb = new AABB(animatable.getX() - 2.0D, animatable.getY() - 2.0D, animatable.getZ() - 2.0D, animatable.getX() + 2.0D, animatable.getY() + 2.0D, animatable.getZ() + 2.0D);
}
return camera.isVisible(aabb);
}
}
}

View File

@ -1,11 +0,0 @@
package ru.magistu.siegemachines.client.renderer;
import ru.magistu.siegemachines.client.renderer.model.MachineItemModel;
public class TrebuchetItemGeoRenderer extends MachineItemGeoRenderer
{
public TrebuchetItemGeoRenderer()
{
super(new MachineItemModel<>("trebuchet"));
}
}

View File

@ -0,0 +1,21 @@
package ru.magistu.siegemachines.config;
import net.minecraftforge.common.ForgeConfigSpec;
public class MissileSpecs
{
public final ForgeConfigSpec.ConfigValue<Float> mass;
public final ForgeConfigSpec.ConfigValue<Float> explosionpower;
public final ForgeConfigSpec.ConfigValue<Boolean> destroysground;
public MissileSpecs(ForgeConfigSpec.Builder builder, String name, float mass, float explosionpower, boolean destroysground)
{
builder.push(name);
this.mass = builder.define("mass", mass);
this.explosionpower = builder.define("explosionRadius", explosionpower);
this.destroysground = builder.define("destroysGround", destroysground);
builder.pop();
}
}

View File

@ -0,0 +1,29 @@
package ru.magistu.siegemachines.config;
import net.minecraftforge.common.ForgeConfigSpec;
public final class SiegeMachineSpecs
{
private final String name;
public final ForgeConfigSpec.ConfigValue<Integer> durability;
public final ForgeConfigSpec.ConfigValue<Integer> delaytime;
public final ForgeConfigSpec.ConfigValue<Float> projectilespeed;
public final ForgeConfigSpec.ConfigValue<Float> inaccuracy;
public final ForgeConfigSpec.ConfigValue<Float> damagemultiplier;
public SiegeMachineSpecs(ForgeConfigSpec.Builder builder, String name, int durability, int delaytime, float projectilespeed, float inaccuracy, float damagemultiplier)
{
this.name = name;
builder.push(name);
this.durability = builder.define("durability", durability);
this.delaytime = builder.define("reloadTime", delaytime);
this.projectilespeed = builder.define("projectileSpeed", projectilespeed);
this.inaccuracy = builder.define("inaccuracy", inaccuracy);
this.damagemultiplier = builder.define("damageMultiplier", damagemultiplier);
builder.pop();
}
}

View File

@ -0,0 +1,53 @@
package ru.magistu.siegemachines.config;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.config.ModConfig;
public final class SpecsConfig
{
public static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
public static final ForgeConfigSpec SPEC;
public static final SiegeMachineSpecs MORTAR;
public static final SiegeMachineSpecs CULVERIN;
public static final SiegeMachineSpecs TREBUCHET;
public static final SiegeMachineSpecs CATAPULT;
public static final SiegeMachineSpecs BALLISTA;
public static final SiegeMachineSpecs BATTERING_RAM;
public static final SiegeMachineSpecs SIEGE_LADDER;
public static final MissileSpecs CANNONBALL;
public static final MissileSpecs STONE;
public static final MissileSpecs GIANT_STONE;
static
{
BUILDER.push("siege_machines");
MORTAR = new SiegeMachineSpecs(BUILDER, "mortar", 80, 200, 2.5f, 0.2f, 1.5f);
CULVERIN = new SiegeMachineSpecs(BUILDER, "culverin", 150, 260, 3.5f, 0.03f, 3.0f);
TREBUCHET = new SiegeMachineSpecs(BUILDER, "trebuchet", 350, 400, 2.8f, 0.2f, 2.0f);
CATAPULT = new SiegeMachineSpecs(BUILDER, "catapult", 150, 200, 2.0f, 0.2f, 1.0f);
BALLISTA = new SiegeMachineSpecs(BUILDER, "ballista", 70, 120, 4.5f, 0.04f, 1.2f);
BATTERING_RAM = new SiegeMachineSpecs(BUILDER, "battering_ram", 500, 100, 0.0f, 0.5f, 0.0f);
SIEGE_LADDER = new SiegeMachineSpecs(BUILDER, "siege_ladder", 400, 0, 0.0f, 0.0f, 0.0f);
BUILDER.pop();
BUILDER.push("missiles");
CANNONBALL = new MissileSpecs(BUILDER, "cannonball", 15.0f, 3.0f, false);
STONE = new MissileSpecs(BUILDER, "stone", 50.0f, 2.0f, false);
GIANT_STONE = new MissileSpecs(BUILDER, "giant_stone", 70.0f, 5.0f, false);
BUILDER.pop();
SPEC = BUILDER.build();
}
public static void register()
{
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, SPEC, "siege-machines-specs.toml");
}
}

View File

@ -4,6 +4,7 @@ import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.entity.machine.*;
import ru.magistu.siegemachines.entity.projectile.Cannonball;
import ru.magistu.siegemachines.entity.projectile.GiantArrow;
import ru.magistu.siegemachines.entity.projectile.GiantStone;
import ru.magistu.siegemachines.entity.projectile.Stone;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
@ -20,18 +21,27 @@ public class EntityTypes
public static final RegistryObject<EntityType<Cannonball>> CANNONBALL = addRegistry("cannonball", Cannonball::new, 0.5f, 0.5f);
public static final RegistryObject<EntityType<Stone>> STONE = addRegistry("stone", Stone::new, 0.6f, 0.6f);
public static final RegistryObject<EntityType<GiantStone>> GIANT_STONE = addRegistry("giant_stone", GiantStone::new, 1.1f, 1.1f);
public static final RegistryObject<EntityType<GiantArrow>> GIANT_ARROW = DEFERRED_REGISTER.register("giant_arrow", () -> EntityType.Builder.<GiantArrow>of(GiantArrow::new, MobCategory.MISC).clientTrackingRange(4).updateInterval(20).sized(0.5f, 0.5f).build(new ResourceLocation(SiegeMachines.ID, "giant_arrow").toString()));
public static final RegistryObject<EntityType<Mortar>> MORTAR = addRegistry("mortar", Mortar::new, 2.0f, 1.0f);
public static final RegistryObject<EntityType<Culverin>> CULVERIN = addRegistry("culverin", Culverin::new, 2.0f, 1.0f);
public static final RegistryObject<EntityType<Trebuchet>> TREBUCHET = addRegistry("trebuchet", Trebuchet::new, 5.0f, 9.0f);
public static final RegistryObject<EntityType<Catapult>> CATAPULT = addRegistry("catapult", Catapult::new, 3.0f, 3.0f);
public static final RegistryObject<EntityType<Ballista>> BALLISTA = addRegistry("ballista", Ballista::new, 1.5f, 1.5f);
public static final RegistryObject<EntityType<BatteringRam>> BATTERING_RAM = addRegistry("battering_ram", BatteringRam::new, 4.0f, 3.0f);
public static final RegistryObject<EntityType<Mortar>> MORTAR = addRegistry("mortar", Mortar::new, 2.0f, 1.0f, 10);
public static final RegistryObject<EntityType<Culverin>> CULVERIN = addRegistry("culverin", Culverin::new, 2.5f, 1.8f, 10);
public static final RegistryObject<EntityType<Trebuchet>> TREBUCHET = addRegistry("trebuchet", Trebuchet::new, 5.0f, 9.0f, 10);
public static final RegistryObject<EntityType<Catapult>> CATAPULT = addRegistry("catapult", Catapult::new, 3.0f, 3.0f, 10);
public static final RegistryObject<EntityType<Ballista>> BALLISTA = addRegistry("ballista", Ballista::new, 1.5f, 1.5f, 10);
public static final RegistryObject<EntityType<BatteringRam>> BATTERING_RAM = addRegistry("battering_ram", BatteringRam::new, 4.0f, 3.0f, 10);
public static final RegistryObject<EntityType<SiegeLadder>> SIEGE_LADDER = addRegistry("siege_ladder", SiegeLadder::new, 3.0f, 3.0f, 10);
public static final RegistryObject<EntityType<Seat>> SEAT = addRegistry("seat", Seat::new, 0.0f, 0.0f);
public static <T extends Entity> RegistryObject<EntityType<T>> addRegistry(String name, EntityType.EntityFactory<T> constructor, float sizex, float sizey)
{
return DEFERRED_REGISTER.register(name, () -> EntityType.Builder.of(constructor, MobCategory.MISC).sized(sizex, sizey).build(new ResourceLocation(SiegeMachines.ID, name).toString()));
return addRegistry(name, constructor, sizex, sizey, 1);
}
public static <T extends Entity> RegistryObject<EntityType<T>> addRegistry(String name, EntityType.EntityFactory<T> constructor, float sizex, float sizey, int trackingrange)
{
return DEFERRED_REGISTER.register(name, () -> EntityType.Builder.of(constructor, MobCategory.MISC).clientTrackingRange(trackingrange).sized(sizex, sizey).build(new ResourceLocation(SiegeMachines.ID, name).toString()));
}
public static void register(IEventBus eventBus)

View File

@ -1,6 +1,6 @@
package ru.magistu.siegemachines.entity;
import ru.magistu.siegemachines.gui.machine.crosshair.Crosshair;
import ru.magistu.siegemachines.client.gui.machine.crosshair.Crosshair;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

View File

@ -2,8 +2,8 @@ package ru.magistu.siegemachines.entity.machine;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.client.SoundTypes;
import ru.magistu.siegemachines.gui.machine.crosshair.Crosshair;
import ru.magistu.siegemachines.gui.machine.crosshair.ReloadingCrosshair;
import ru.magistu.siegemachines.client.gui.machine.crosshair.Crosshair;
import ru.magistu.siegemachines.client.gui.machine.crosshair.ReloadingCrosshair;
import ru.magistu.siegemachines.item.ModItems;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
@ -59,21 +59,21 @@ public class Ballista extends ShootingMachine implements IAnimatable
}
}
return PlayState.CONTINUE;
}
}
@Override
public void registerControllers(AnimationData data)
public void registerControllers(AnimationData data)
{
AnimationController<?> controller = new AnimationController<>(this, "controller", 1, (t) ->
{
if (this.state.equals(State.RELOADING))
{
return (double) (this.type.delaytime - this.delayticks) / this.type.delaytime;
return (double) (this.type.specs.delaytime.get() - this.delayticks) / this.type.specs.delaytime.get();
}
return t;
}, this::predicate);
data.addAnimationController(controller);
}
data.addAnimationController(controller);
}
@Override
public AnimationFactory getFactory()
@ -90,11 +90,11 @@ public class Ballista extends ShootingMachine implements IAnimatable
}
if (!this.level.isClientSide() && !this.isVehicle())
{
player.startRiding(this);
return InteractionResult.SUCCESS;
}
player.startRiding(this);
return InteractionResult.SUCCESS;
}
return InteractionResult.PASS;
return InteractionResult.PASS;
}
public void startShooting(Player player)
@ -106,7 +106,7 @@ public class Ballista extends ShootingMachine implements IAnimatable
this.shootingticks = this.type.userealisetime;
Vec3 pos = this.position();
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.BALLISTA_SHOOTING.get(), SoundSource.BLOCKS, 1.4f, 1.0f, false);
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.BALLISTA_SHOOTING.get(), this.getSoundSource(), 1.4f, 1.0f, false);
}
}
@ -120,21 +120,21 @@ public class Ballista extends ShootingMachine implements IAnimatable
}
// @Override
// public void travel(Vec3 pos)
// public void travel(Vec3 pos)
// {
// if (this.isAlive())
// if (this.isAlive())
// {
// if (this.isVehicle())
// {
// LivingEntity livingentity = (LivingEntity) this.getControllingPassenger();
// LivingEntity livingentity = (LivingEntity) this.getControllingPassenger();
//
// this.setTurretRotationsDest(livingentity.getXRot(), livingentity.getYRot() - this.getYaw());
// this.updateTurretRotations();
// }
// }
// super.travel(pos);
// }
// }
//
// }
// }
@Override
public void travel(Vec3 pos)
@ -163,7 +163,7 @@ public class Ballista extends ShootingMachine implements IAnimatable
{
this.state = State.RELOADING;
this.useticks = 0;
this.delayticks = this.type.delaytime;
this.delayticks = this.type.specs.delaytime.get();
}
if (this.shootingticks != 0 && --this.shootingticks <= 0)
@ -182,7 +182,7 @@ public class Ballista extends ShootingMachine implements IAnimatable
if (this.delayticks % 21 == 0)
{
Vec3 pos = this.position();
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.BALLISTA_RELOADING.get(), SoundSource.BLOCKS, 1.0f, 1.0f, false);
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.BALLISTA_RELOADING.get(), this.getSoundSource(), 1.0f, 1.0f, false);
}
--this.delayticks;
}

View File

@ -1,5 +1,9 @@
package ru.magistu.siegemachines.entity.machine;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.client.SoundTypes;
import ru.magistu.siegemachines.entity.Breakdown;
@ -19,6 +23,7 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import ru.magistu.siegemachines.util.CartesianGeometry;
import software.bernie.geckolib3.core.IAnimatable;
import software.bernie.geckolib3.core.PlayState;
import software.bernie.geckolib3.core.builder.AnimationBuilder;
@ -91,7 +96,7 @@ public class BatteringRam extends Machine implements IAnimatable
{
if (this.state.equals(State.RELOADING))
{
return (double) (this.type.delaytime - this.delayticks) / this.type.delaytime;
return (double) (this.type.specs.delaytime.get() - this.delayticks) / this.type.specs.delaytime.get();
}
return t;
}, this::reloading_predicate);
@ -149,7 +154,7 @@ public class BatteringRam extends Machine implements IAnimatable
{
this.state = State.RELOADING;
this.useticks = 0;
this.delayticks = this.type.delaytime;
this.delayticks = this.type.specs.delaytime.get();
}
if (this.hittingticks != 0 && --this.hittingticks <= 0)
@ -173,12 +178,17 @@ public class BatteringRam extends Machine implements IAnimatable
this.updateMachineRender();
this.renderupdateticks = SiegeMachines.RENDER_UPDATE_TIME;
}
// if (this.getWheelsSpeed() > 0.0081 && this.wheelssoundticks-- <= 0)
// {
// this.level.playLocalSound(this.getX(), this.getY(), this.getZ(), SoundTypes.RAM_WHEELS.get(), SoundCategory.NEUTRAL, 0.6f, 1.0f, true);
// this.wheelssoundticks = 20;
// }
if (this.level.isClientSide() && this.hasControllingPassenger() && this.getWheelsSpeed() > 0.0081 && this.wheelssoundticks-- <= 0)
{
Entity passenger = this.getControllingPassenger();
if (Minecraft.getInstance().player == passenger)
{
Vec3 pos = this.position();
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.RAM_WHEELS.get(), this.getSoundSource(), 1.5f, 0.85f + this.level.random.nextFloat() * 0.3f, false);
this.wheelssoundticks = 20;
}
}
super.tick();
}
@ -186,10 +196,14 @@ public class BatteringRam extends Machine implements IAnimatable
@Override
public void use(Player player)
{
if (!this.level.isClientSide())
if (this.deploymentticks > 0)
{
PacketHandler.sendPacketToAllInArea(new PacketMachineUse(this.getId()), this.blockPosition(), SiegeMachines.RENDER_UPDATE_RANGE_SQR);
player.sendSystemMessage(Component.translatable(SiegeMachines.ID + ".wait", this.deploymentticks / 20.0f).withStyle(ChatFormatting.RED));
return;
}
if (!this.level.isClientSide())
PacketHandler.sendPacketToAllInArea(new PacketMachineUse(this.getId()), this.blockPosition(), SiegeMachines.RENDER_UPDATE_RANGE_SQR);
if (this.delayticks <= 0 && this.useticks <= 0 && this.hittingticks <= 0)
{
@ -198,7 +212,7 @@ public class BatteringRam extends Machine implements IAnimatable
this.hittingticks = this.type.userealisetime;
Vec3 pos = this.position();
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.RAM_HITTING.get(), SoundSource.BLOCKS, 0.5f, 0.9f, false);
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.RAM_HITTING.get(), this.getSoundSource(), 0.5f, 0.9f, false);
}
}
@ -215,6 +229,9 @@ public class BatteringRam extends Machine implements IAnimatable
@Override
public void useRealise()
{
if (this.deploymentticks > 0)
return;
if (!this.level.isClientSide())
{
PacketHandler.sendPacketToAllInArea(new PacketMachineUseRealise(this.getId()), this.blockPosition(), SiegeMachines.RENDER_UPDATE_RANGE_SQR);
@ -251,6 +268,6 @@ public class BatteringRam extends Machine implements IAnimatable
double pitch = this.getTurretPitch() * Math.PI / 180.0;
double yaw = (this.getViewYRot(0.5f) + this.getTurretYaw()) * Math.PI / 180.0;
return this.position().add(applyRotations(this.type.turretpivot, 0.0, yaw).add(applyRotations(this.type.turretvector, pitch, yaw)));
return this.position().add(CartesianGeometry.applyRotations(this.type.turretpivot, 0.0, yaw).add(CartesianGeometry.applyRotations(this.type.turretvector, pitch, yaw)));
}
}

View File

@ -2,8 +2,8 @@ package ru.magistu.siegemachines.entity.machine;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.client.SoundTypes;
import ru.magistu.siegemachines.gui.machine.crosshair.Crosshair;
import ru.magistu.siegemachines.gui.machine.crosshair.ReloadingCrosshair;
import ru.magistu.siegemachines.client.gui.machine.crosshair.Crosshair;
import ru.magistu.siegemachines.client.gui.machine.crosshair.ReloadingCrosshair;
import ru.magistu.siegemachines.item.ModItems;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
@ -73,21 +73,21 @@ public class Catapult extends ShootingMachine implements IAnimatable
}
return PlayState.CONTINUE;
}
}
@Override
public void registerControllers(AnimationData data)
public void registerControllers(AnimationData data)
{
AnimationController<?> controller = new AnimationController<>(this, "controller", 1, (t) ->
{
if (this.state.equals(State.RELOADING))
{
return (double) (this.type.delaytime - this.delayticks) / this.type.delaytime;
return (double) (this.type.specs.delaytime.get() - this.delayticks) / this.type.specs.delaytime.get();
}
return t;
}, this::predicate);
data.addAnimationController(controller);
}
data.addAnimationController(controller);
}
@Override
public AnimationFactory getFactory()
@ -106,11 +106,11 @@ public class Catapult extends ShootingMachine implements IAnimatable
}
if (!this.level.isClientSide() && !this.isVehicle())
{
player.startRiding(this);
return InteractionResult.SUCCESS;
}
player.startRiding(this);
return InteractionResult.SUCCESS;
}
return InteractionResult.PASS;
return InteractionResult.PASS;
}
public void startShooting(Player player)
@ -122,7 +122,7 @@ public class Catapult extends ShootingMachine implements IAnimatable
this.shootingticks = this.type.userealisetime;
Vec3 pos = this.position();
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.CATAPULT_SHOOTING.get(), SoundSource.BLOCKS, 1.5f, 1.0f, false);
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.CATAPULT_SHOOTING.get(), this.getSoundSource(), 1.5f, 1.0f, false);
}
}
@ -136,23 +136,23 @@ public class Catapult extends ShootingMachine implements IAnimatable
}
@Override
public void travel(Vec3 pos)
public void travel(Vec3 pos)
{
if (this.isAlive())
if (this.isAlive())
{
if (this.isVehicle() && this.useticks <= 0 && this.delayticks <= 0)
{
LivingEntity livingentity = (LivingEntity) this.getControllingPassenger();
LivingEntity livingentity = (LivingEntity) this.getControllingPassenger();
this.setTurretRotations(livingentity.getXRot(), this.getTurretYaw());
this.updateTurretRotations();
this.setYawDest(livingentity.getYRot());
this.updateYaw();
}
}
super.travel(pos);
}
}
}
}
@Override
public void tick()
@ -161,7 +161,7 @@ public class Catapult extends ShootingMachine implements IAnimatable
{
this.state = State.RELOADING;
this.useticks = 0;
this.delayticks = this.type.delaytime;
this.delayticks = this.type.specs.delaytime.get();
}
if (this.shootingticks != 0 && --this.shootingticks <= 0)
@ -180,7 +180,7 @@ public class Catapult extends ShootingMachine implements IAnimatable
if (this.delayticks % 20 == 0)
{
Vec3 pos = this.position();
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.CATAPULT_RELOADING.get(), SoundSource.BLOCKS, 1.0f, 1.0f, false);
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.CATAPULT_RELOADING.get(), this.getSoundSource(), 1.0f, 1.0f, false);
}
if (--this.delayticks <= 0)
{

View File

@ -1,14 +1,7 @@
package ru.magistu.siegemachines.entity.machine;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.client.SoundTypes;
import ru.magistu.siegemachines.entity.IReloading;
import ru.magistu.siegemachines.gui.machine.crosshair.Crosshair;
import ru.magistu.siegemachines.gui.machine.crosshair.ReloadingCrosshair;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
@ -21,6 +14,12 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.client.SoundTypes;
import ru.magistu.siegemachines.entity.IReloading;
import ru.magistu.siegemachines.client.gui.machine.crosshair.Crosshair;
import ru.magistu.siegemachines.client.gui.machine.crosshair.ReloadingCrosshair;
import ru.magistu.siegemachines.item.ModItems;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import software.bernie.geckolib3.core.IAnimatable;
@ -46,6 +45,9 @@ public class Culverin extends ShootingMachine implements IAnimatable, IReloading
public Culverin(EntityType<? extends Mob> entitytype, Level level)
{
super(entitytype, level, MachineType.CULVERIN);
this.turretpitch = -18.5f;
this.turretpitchprev = this.turretpitch;
this.turretpitchdest = this.turretpitch;
}
private <E extends IAnimatable> PlayState wheels_predicate(AnimationEvent<E> event)
@ -53,18 +55,18 @@ public class Culverin extends ShootingMachine implements IAnimatable, IReloading
event.getController().setAnimation(MOVING_ANIM);
return PlayState.CONTINUE;
}
}
@Override
public void registerControllers(AnimationData data)
public void registerControllers(AnimationData data)
{
AnimationController<?> wheels_controller = new AnimationController<>(this, "wheels_controller", 1, (t) -> {
double d = this.getWheelsSpeed();
this.wheelsspeed = d > 0 ? Math.min(d, 1.0) : Math.max(d, -1.0);
return wheelspitch += 0.013 * this.wheelsspeed;
return wheelspitch += 0.015 * this.wheelsspeed;
}, this::wheels_predicate);
data.addAnimationController(wheels_controller);
}
data.addAnimationController(wheels_controller);
}
@Override
public AnimationFactory getFactory()
@ -79,7 +81,7 @@ public class Culverin extends ShootingMachine implements IAnimatable, IReloading
if (stack.getItem().equals(Items.FLINT_AND_STEEL))
{
if (this.useticks <= 0 && this.shootingticks <= 0)
if (this.useticks < 0)
{
stack.hurtAndBreak(1, player, (p_213833_1_) ->
{
@ -108,21 +110,21 @@ public class Culverin extends ShootingMachine implements IAnimatable, IReloading
}
if (!this.level.isClientSide() && !this.isVehicle())
{
player.startRiding(this);
return InteractionResult.SUCCESS;
}
player.startRiding(this);
return InteractionResult.SUCCESS;
}
return InteractionResult.PASS;
return InteractionResult.PASS;
}
@Override
public void travel(Vec3 pos)
public void travel(Vec3 pos)
{
if (this.isAlive())
if (this.isAlive())
{
if (this.isVehicle())
{
LivingEntity livingentity = (LivingEntity) this.getControllingPassenger();
LivingEntity livingentity = (LivingEntity) this.getControllingPassenger();
this.setTurretRotationsDest(livingentity.getXRot(), livingentity.getYRot() - this.getYaw());
this.setYawDest(livingentity.getYRot());
@ -130,51 +132,31 @@ public class Culverin extends ShootingMachine implements IAnimatable, IReloading
this.updateYaw();
this.updateTurretRotations();
float f0 = livingentity.xxa * 0.2f;
float f1 = livingentity.zza;
if (f1 <= 0.0f)
{
f1 *= 0.5f;
}
this.setSpeed(0.04f);
float f0 = livingentity.xxa * 0.2f;
float f1 = livingentity.zza;
this.setSpeed(0.02f);
pos = new Vec3(f0, pos.y, f1);
}
}
super.travel(pos);
}
}
}
}
@Override
public void tick()
{
if (this.useticks != 0 && --this.useticks <= 0)
{
this.useticks = 0;
this.delayticks = this.type.delaytime;
}
if (this.shootingticks != 0 && --this.shootingticks <= 0)
{
if (this.inventory.containsItem(Items.GUNPOWDER))
{
this.useRealise();
}
else if (!this.level.isClientSide())
{
Entity passenger = this.getControllingPassenger();
if (passenger instanceof Player)
{
passenger.sendSystemMessage(Component.translatable(SiegeMachines.ID + ".no_gunpowder").withStyle(ChatFormatting.RED));
}
}
this.shootingticks = 0;
this.useticks = 0;
}
if (!level.isClientSide() && this.isOnGround())
if (!level.isClientSide() && (this.isOnGround() || this.isInWater()))
{
this.setDeltaMovement(this.getWheelsDeltaMovement());
}
if (this.delayticks > 0 && this.isVehicle())
{
--this.delayticks;
@ -186,10 +168,15 @@ public class Culverin extends ShootingMachine implements IAnimatable, IReloading
this.renderupdateticks = SiegeMachines.RENDER_UPDATE_TIME;
}
if (this.getWheelsSpeed() > 0.0081 && this.wheelssoundticks-- <= 0)
if (this.level.isClientSide() && this.hasControllingPassenger() && this.getWheelsSpeed() > 0.0081 && this.wheelssoundticks-- <= 0)
{
this.level.playLocalSound(this.getX(), this.getY(), this.getZ(), SoundTypes.CANNON_WHEELS.get(), SoundSource.NEUTRAL, 0.3f, 1.0f, true);
this.wheelssoundticks = 20;
Entity passenger = this.getControllingPassenger();
if (Minecraft.getInstance().player == passenger)
{
Vec3 pos = this.position();
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.CANNON_WHEELS.get(), this.getSoundSource(), 1.5f, 0.85f + this.level.random.nextFloat() * 0.3f, false);
this.wheelssoundticks = 20;
}
}
super.tick();
@ -198,14 +185,13 @@ public class Culverin extends ShootingMachine implements IAnimatable, IReloading
@Override
public void startShooting(Player player)
{
if (this.delayticks <= 0 && this.useticks <= 0 && this.shootingticks <= 0)
if (this.delayticks <= 0 && this.useticks <= 0)
{
if (!this.level.isClientSide())
{
this.level.playSound(null, this.getX(), this.getY(), this.getZ(), SoundTypes.FUSE.get(), SoundSource.BLOCKS, this.getVolumeFromDist(this.distanceTo(player)), 0.8f);
this.level.playSound(null, this.getX(), this.getY(), this.getZ(), SoundTypes.FUSE.get(), this.getSoundSource(), this.getVolumeFromDist(this.distanceTo(player)), 0.8f);
}
this.useticks = this.type.usetime;
this.shootingticks = this.type.userealisetime;
}
}
@ -224,8 +210,10 @@ public class Culverin extends ShootingMachine implements IAnimatable, IReloading
this.blowParticles(ParticleTypes.FLAME, 0.035, 25);
this.blowParticles(ParticleTypes.CLOUD, 0.2, 60);
Vec3 pos = this.position();
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.MORTAR_SHOOTING.get(), SoundSource.BLOCKS, 1.5f/*this.getVolumeFromDist(1.5f, 64.0f, this.distanceTo(player))*/, 0.85f + this.level.random.nextFloat() * 0.3f, false);
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.MORTAR_SHOOTING.get(), this.getSoundSource(), 1.5f/*this.getVolumeFromDist(1.5f, 64.0f, this.distanceTo(player))*/, 0.85f + this.level.random.nextFloat() * 0.3f, false);
}
this.delayticks = this.type.specs.delaytime.get();
}
public double getWheelsSpeed()
@ -267,7 +255,6 @@ public class Culverin extends ShootingMachine implements IAnimatable, IReloading
@Override
public Item getMachineItem()
{
return null;
// return ModItems.CULVERIN.get();
return ModItems.CULVERIN.get();
}
}

View File

@ -0,0 +1,75 @@
package ru.magistu.siegemachines.entity.machine;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import ru.magistu.siegemachines.entity.EntityTypes;
public class LadderSeat extends Seat
{
public final float climbspeed = 0.02f;
private float highness = 0.0f;
public final SiegeLadder parent;
public LadderSeat(SiegeLadder parent)
{
super(EntityTypes.SEAT.get(), parent.level);
this.parent = parent;
}
public float getHighness()
{
return this.highness;
}
public void setHighness(float highness)
{
this.highness = highness;
}
@Override
public InteractionResult interact(Player player, InteractionHand hand)
{
InteractionResult result = super.interact(player, hand);
if (result.consumesAction())
return result;
if (player.isSecondaryUseActive())
return InteractionResult.PASS;
else if (this.isVehicle())
return InteractionResult.PASS;
else if (!this.level.isClientSide)
return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS;
else
return InteractionResult.SUCCESS;
}
@Override
public boolean shouldRiderSit()
{
return false;
}
@Override
protected void removePassenger(Entity entity)
{
this.highness = 0.0f;
super.removePassenger(entity);
}
public float climb()
{
if (this.getFirstPassenger() instanceof LivingEntity livingentity)
{
if (livingentity.zza < -this.climbspeed && this.highness >= this.climbspeed)
return this.highness - this.climbspeed;
if (livingentity.zza > this.climbspeed && this.highness <= 1.0f - this.climbspeed)
return this.highness + this.climbspeed;
}
return this.highness;
}
}

View File

@ -1,7 +1,9 @@
package ru.magistu.siegemachines.entity.machine;
import net.minecraft.client.KeyMapping;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.gui.machine.MachineContainer;
import ru.magistu.siegemachines.client.KeyBindings;
import ru.magistu.siegemachines.client.gui.machine.MachineContainer;
import ru.magistu.siegemachines.network.PacketHandler;
import ru.magistu.siegemachines.network.PacketMachine;
import net.minecraft.advancements.CriteriaTriggers;
@ -35,22 +37,21 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.network.NetworkHooks;
import org.jetbrains.annotations.NotNull;
import ru.magistu.siegemachines.util.CartesianGeometry;
import javax.annotation.Nullable;
public abstract class Machine extends Mob implements MenuProvider
{
public MachineInventory inventory = new MachineInventory();
public static int rows = 1;
public KeyMapping usekey;
public MachineInventory inventory;
public final MachineType type;
private float turretpitch = -25.0f;
private float turretpitchprev = this.turretpitch;
protected float turretpitch = -25.0f;
protected float turretpitchprev = this.turretpitch;
protected float turretpitchdest = this.turretpitch;
private float turretyaw = 0.0f;
private float turretyawprev = this.turretyaw;
protected float turretyaw = 0.0f;
protected float turretyawprev = this.turretyaw;
protected float turretyawdest = this.turretyaw;
protected float yawdest = this.getYRot();
@ -63,13 +64,18 @@ public abstract class Machine extends Mob implements MenuProvider
{
super(entitytype, level);
this.type = type;
this.delayticks = this.type.delaytime;
rows = this.type.rows;
this.delayticks = this.type.specs.delaytime.get();
this.inventory = new MachineInventory(9 * this.type.containerrows);
if (level.isClientSide())
this.usekey = KeyBindings.getUseKey(type);
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(type.specs.durability.get());
this.setHealth(type.specs.durability.get());
}
public static AttributeSupplier.Builder setEntityAttributes(MachineType type) {
return Mob.createMobAttributes()
.add(Attributes.MAX_HEALTH, type.health)
.add(Attributes.MAX_HEALTH, type.specs.durability.getDefault())
.add(Attributes.KNOCKBACK_RESISTANCE, 0.5F)
.add(Attributes.MOVEMENT_SPEED, 0.0D)
.add(Attributes.ATTACK_DAMAGE, 0.0D)
@ -138,148 +144,141 @@ public abstract class Machine extends Mob implements MenuProvider
@Override
public boolean hurt(@NotNull DamageSource damagesource, float f) {
if (!net.minecraftforge.common.ForgeHooks.onLivingAttack(this, damagesource, f)) return false;
if (damagesource.getEntity() instanceof Player
&& !damagesource.isProjectile()
&& !damagesource.isExplosion()
&& !damagesource.isMagic()
&& this.getPassengers().isEmpty()) {
if (this.isInvulnerableTo(damagesource))
return false;
if (this.level.isClientSide)
return false;
if (this.isDeadOrDying())
return false;
if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE))
return false;
if (damagesource.getEntity() instanceof Player && !damagesource.isProjectile() && !damagesource.isExplosion() && !damagesource.isMagic() && this.getPassengers().isEmpty())
{
this.spawnAtLocation(this.getMachineItemWithData());
this.remove();
return false;
}
if (this.isInvulnerableTo(damagesource)) {
return false;
} else if (this.level.isClientSide) {
return false;
} else if (this.isDeadOrDying()) {
return false;
} else if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
return false;
} else {
f = adjustDamage(damagesource, f);
}
f = adjustDamage(damagesource, f);
this.noActionTime = 0;
this.noActionTime = 0;
this.animationSpeed = 1.5F;
boolean flag1 = true;
if ((float) this.invulnerableTime > 10.0F)
this.animationSpeed = 1.5F;
boolean flag1 = true;
if ((float) this.invulnerableTime > 10.0F)
{
if (f <= this.lastHurt)
{
if (f <= this.lastHurt)
{
return false;
}
this.actuallyHurt(damagesource, f - this.lastHurt);
this.lastHurt = f;
flag1 = false;
}
else
{
this.lastHurt = f;
this.invulnerableTime = 20;
this.actuallyHurt(damagesource, f);
this.hurtDuration = 10;
this.hurtTime = this.hurtDuration;
return false;
}
this.hurtDir = 0.0F;
Entity entity1 = damagesource.getEntity();
if (entity1 != null)
this.actuallyHurt(damagesource, f - this.lastHurt);
this.lastHurt = f;
flag1 = false;
}
else
{
this.lastHurt = f;
this.invulnerableTime = 20;
this.actuallyHurt(damagesource, f);
this.hurtDuration = 10;
this.hurtTime = this.hurtDuration;
}
this.hurtDir = 0.0F;
Entity entity1 = damagesource.getEntity();
if (entity1 != null)
{
if (entity1 instanceof LivingEntity)
{
if (entity1 instanceof LivingEntity)
{
this.setLastHurtByMob((LivingEntity) entity1);
}
if (entity1 instanceof Player)
{
this.lastHurtByPlayerTime = 1;
this.lastHurtByPlayer = (Player) entity1;
}
else if (entity1 instanceof TamableAnimal wolfEntity) {
if (wolfEntity.isTame()) {
this.lastHurtByPlayerTime = 100;
LivingEntity livingentity = wolfEntity.getOwner();
if (livingentity != null && livingentity.getType() == EntityType.PLAYER) {
this.lastHurtByPlayer = (Player) livingentity;
}
else {
this.lastHurtByPlayer = null;
}
}
}
this.setLastHurtByMob((LivingEntity) entity1);
}
if (flag1) {
if (damagesource instanceof EntityDamageSource && ((EntityDamageSource) damagesource).isThorns()) {
this.level.broadcastEntityEvent(this, (byte) 33);
}
if (entity1 instanceof Player)
{
this.lastHurtByPlayerTime = 1;
this.lastHurtByPlayer = (Player) entity1;
}
else {
byte b0;
else if (entity1 instanceof TamableAnimal wolfEntity) {
if (wolfEntity.isTame()) {
this.lastHurtByPlayerTime = 100;
LivingEntity livingentity = wolfEntity.getOwner();
if (damagesource.isFire()) {
b0 = 37;
}
else if (damagesource == DamageSource.SWEET_BERRY_BUSH) {
b0 = 44;
if (livingentity != null && livingentity.getType() == EntityType.PLAYER) {
this.lastHurtByPlayer = (Player) livingentity;
}
else {
b0 = 2;
this.lastHurtByPlayer = null;
}
this.level.broadcastEntityEvent(this, b0);
}
this.markHurt();
if (entity1 != null)
{
double d1 = entity1.getX() - this.getX();
double d0;
for (d0 = entity1.getZ() - this.getZ(); d1 * d1 + d0 * d0 < 1.0E-4D; d0 = (Math.random() - Math.random()) * 0.01D)
{
d1 = (Math.random() - Math.random()) * 0.01D;
}
this.hurtDir = (float) (Mth.atan2(d0, d1) * (double) (180F / (float) Math.PI) - (double) this.getYRot());
}
else
{
this.hurtDir = (float) ((int) (Math.random() * 2.0D) * 180);
}
}
if (this.isDeadOrDying())
{
SoundEvent soundevent = this.getDeathSound();
if (flag1 && soundevent != null)
{
this.playSound(soundevent, this.getSoundVolume(), this.getVoicePitch());
}
this.die(damagesource);
}
else if (flag1)
{
this.playHurtSound(damagesource);
}
if (entity1 instanceof ServerPlayer)
{
CriteriaTriggers.PLAYER_HURT_ENTITY.trigger((ServerPlayer) entity1, this, damagesource, f, f, false);
}
return true;
}
if (flag1) {
if (damagesource instanceof EntityDamageSource && ((EntityDamageSource) damagesource).isThorns()) {
this.level.broadcastEntityEvent(this, (byte) 33);
}
else {
byte b0;
if (damagesource.isFire()) {
b0 = 37;
}
else if (damagesource == DamageSource.SWEET_BERRY_BUSH) {
b0 = 44;
}
else {
b0 = 2;
}
this.level.broadcastEntityEvent(this, b0);
}
this.markHurt();
if (entity1 != null)
{
double d1 = entity1.getX() - this.getX();
double d0;
for (d0 = entity1.getZ() - this.getZ(); d1 * d1 + d0 * d0 < 1.0E-4D; d0 = (Math.random() - Math.random()) * 0.01D)
{
d1 = (Math.random() - Math.random()) * 0.01D;
}
this.hurtDir = (float) (Mth.atan2(d0, d1) * (double) (180F / (float) Math.PI) - (double) this.getYRot());
}
else
{
this.hurtDir = (float) ((int) (Math.random() * 2.0D) * 180);
}
}
if (this.isDeadOrDying())
{
SoundEvent soundevent = this.getDeathSound();
if (flag1 && soundevent != null)
{
this.playSound(soundevent, this.getSoundVolume(), this.getVoicePitch());
}
this.die(damagesource);
}
else if (flag1)
{
this.playHurtSound(damagesource);
}
if (entity1 instanceof ServerPlayer)
{
CriteriaTriggers.PLAYER_HURT_ENTITY.trigger((ServerPlayer) entity1, this, damagesource, f, f, false);
}
return true;
}
@Override
@ -332,7 +331,7 @@ public abstract class Machine extends Mob implements MenuProvider
}
nbt.put("Items", listnbt);
nbt.put("TurretRotations", this.newFloatList(this.turretpitch, this.turretyaw));
nbt.putInt("DealyTicks", this.delayticks);
nbt.putInt("DelayTicks", this.delayticks);
nbt.putInt("UseTicks", this.useticks);
}
@ -430,9 +429,9 @@ public abstract class Machine extends Mob implements MenuProvider
ListTag turretrotations = nbt.getList("TurretRotations", 5);
setTurretRotations(turretrotations.getFloat(0), turretrotations.getFloat(1));
}
if (nbt.contains("DealyTicks"))
if (nbt.contains("DelayTicks"))
{
this.delayticks = nbt.getInt("DealyTicks");
this.delayticks = nbt.getInt("DelayTicks");
}
if (nbt.contains("UseTicks"))
{
@ -613,7 +612,7 @@ public abstract class Machine extends Mob implements MenuProvider
public Vec3 getDismountLocationForPassenger(LivingEntity entity) {
double yaw = (this.getGlobalTurretYaw()) * Math.PI / 180.0;
return this.position().add(applyRotations(this.type.passengerpos, 0.0, yaw));
return this.position().add(CartesianGeometry.applyRotations(this.type.passengerpos, 0.0, yaw));
}
@Override
@ -626,18 +625,27 @@ public abstract class Machine extends Mob implements MenuProvider
MoveFunction setPos = Entity::setPos;
if (this.hasPassenger(entity)) {
double yaw = (this.getGlobalTurretYaw()) * Math.PI / 180.0;
Vec3 pos = this.position().add(applyRotations(this.type.passengerpos, 0.0, yaw));
Vec3 pos = this.position().add(CartesianGeometry.applyRotations(this.type.passengerpos, 0.0, yaw));
setPos.accept(entity, pos.x, pos.y, pos.z);
}
}
public static class MachineInventory implements Container, Nameable {
public NonNullList<ItemStack> items = NonNullList.withSize(9 * rows, ItemStack.EMPTY);
public static class MachineInventory implements Container, Nameable
{
private final int containersize;
public NonNullList<ItemStack> items;
public MachineInventory(int rows)
{
this.containersize = 9 * rows;
this.items = NonNullList.withSize(this.containersize, ItemStack.EMPTY);
}
@Override
public int getContainerSize() {
return 9 * rows;
public int getContainerSize()
{
return this.containersize;
}
@Override
@ -675,8 +683,9 @@ public abstract class Machine extends Mob implements MenuProvider
}
@Override
public void clearContent() {
this.items = NonNullList.withSize(9 * rows, ItemStack.EMPTY);
public void clearContent()
{
this.items = NonNullList.withSize(this.containersize, ItemStack.EMPTY);
}
public boolean containsItem(Item item) {

View File

@ -1,71 +1,99 @@
package ru.magistu.siegemachines.entity.machine;
import ru.magistu.siegemachines.entity.projectile.ProjectileBuilder;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.phys.Vec3;
import ru.magistu.siegemachines.config.SiegeMachineSpecs;
import ru.magistu.siegemachines.config.SpecsConfig;
import ru.magistu.siegemachines.entity.projectile.ProjectileBuilder;
import ru.magistu.siegemachines.item.ModItems;
public enum MachineType {
MORTAR(80, 1, 0.0f, 85.0f, 0.0f, 0.0f, 0.5f, 0.5f, true, 10, 10, 200,
public class MachineType
{
public static MachineType MORTAR = new MachineType(
SpecsConfig.MORTAR, 1, 0.0f, 85.0f, 0.0f, 0.0f, 0.5f, 0.5f, true, 10, 10,
new Vec3(17.0, 0.0, -10.0).scale(1 / 16.0), new Vec3(0.0, 17.0, 7.0).scale(1 / 16.0), new Vec3(0.0, 0.0, 12.0).scale(1 / 16.0),
2.5f, 0.2f, ProjectileBuilder.CANNON_AMMO, true),
CULVERIN(80, 1, 0.0f, 85.0f, 0.0f, 0.0f, 0.5f, 0.5f, true, 10, 10, 200,
new Vec3(30.0, 0.0, -40.0).scale(1 / 16.0), new Vec3(0.0, 17.0, 7.0).scale(1 / 16.0), new Vec3(0.0, 0.0, 12.0).scale(1 / 16.0),
3.0f, 0.2f, ProjectileBuilder.CANNON_AMMO, true),
TREBUCHET(300, 1, -45.0f, 75.0f, 0.0f, 0.0f, 0.1f, 0.5f, true, 38, 137, 400,
new Vec3(40.0, 0.0, -60.0).scale(1 / 16.0), new Vec3(0.0, 19.0, -3.0), new Vec3(0.0, 10.0, -1.0),
2.8f, 0.2f, ProjectileBuilder.THROWING_AMMO, false),
CATAPULT(100, 1, 0.0f, 75.0f, 0.0f, 0.0f, 0.2f, 1.0f, true, 2, 10, 200,
new Vec3(30.0, 0.0, -40.0).scale(1 / 16.0), new Vec3(0.0, 51.0, -5.0).scale(1 / 16.0), new Vec3(0.0, 0.0, 0.0),
2.0f, 0.2f, ProjectileBuilder.THROWING_AMMO, false),
BALLISTA(50, 1, -30.0f, 60.0f, -180.0f, 180.0f, 4.5f, 0.0f, false, 1, 20, 120,
new Vec3(0.0, 0.0, -30.0).scale(1 / 16.0), new Vec3(0.0, 22.5, 0.0).scale(1 / 16.0), new Vec3(0.0, 0.0, 17.0).scale(1 / 16.0),
4.5f, 0.04f, ProjectileBuilder.BALLISTA_AMMO, false),
BATTERING_RAM(250, 1, 0.0f, 0.0f, 0.0f, 0.0f, 0.1f, 0.0f, false, 5, 5, 100,
new Vec3(12.0, 0.0, -48.0).scale(1 / 16.0), new Vec3(0.0, 26.0, 36.0).scale(1 / 16.0), new Vec3(0.0, 0.0, 32.0).scale(1 / 16.0),
0.0f, 0.5f, ProjectileBuilder.NO_AMMO, false);
ProjectileBuilder.CANNON_AMMO, true,
new ItemStack[] {new ItemStack(Items.OAK_PLANKS, 2), new ItemStack(ModItems.BEAM.get(), 1), new ItemStack(Items.STICK, 5), new ItemStack(Items.IRON_NUGGET, 21)});
public final int health;
public final int rows;
public static MachineType CULVERIN = new MachineType(
SpecsConfig.CULVERIN, 1, 4.0f, 18.5f, 0.0f, 0.0f, 0.4f, 0.1f, true, 10, 10,
new Vec3(15.0, 0.0, -35.0).scale(1 / 16.0), new Vec3(0.0, 18.0, 18.0).scale(1 / 16.0), new Vec3(0.0, 8.0, 12.0).scale(1 / 16.0),
ProjectileBuilder.CANNON_AMMO, true,
new ItemStack[] {new ItemStack(Items.OAK_PLANKS, 3), new ItemStack(ModItems.BEAM.get(), 2), new ItemStack(Items.STICK, 10), new ItemStack(Items.IRON_NUGGET, 32)});
public static MachineType TREBUCHET = new MachineType(
SpecsConfig.TREBUCHET, 1, -45.0f, 75.0f, 0.0f, 0.0f, 0.05f, 0.5f, true, 38, 137,
new Vec3(40.0, 0.0, -60.0).scale(1 / 16.0), new Vec3(0.0, 19.0, -3.0), new Vec3(0.0, 10.0, -1.0),
ProjectileBuilder.GIANT_THROWING_AMMO, false,
new ItemStack[] {new ItemStack(Items.OAK_PLANKS, 8), new ItemStack(ModItems.BEAM.get(), 12), new ItemStack(Items.STICK, 20), new ItemStack(Items.IRON_NUGGET, 36), new ItemStack(Items.COBBLESTONE, 2)});
public static MachineType CATAPULT = new MachineType(
SpecsConfig.CATAPULT, 1, 0.0f, 75.0f, 0.0f, 0.0f, 0.2f, 1.0f, true, 2, 10,
new Vec3(30.0, 0.0, -40.0).scale(1 / 16.0), new Vec3(0.0, 51.0, -5.0).scale(1 / 16.0), new Vec3(0.0, 0.0, 0.0),
ProjectileBuilder.THROWING_AMMO, false,
new ItemStack[] {new ItemStack(Items.OAK_PLANKS, 5), new ItemStack(ModItems.BEAM.get(), 6), new ItemStack(Items.STICK, 10), new ItemStack(Items.IRON_NUGGET, 14)});
public static MachineType BALLISTA = new MachineType(
SpecsConfig.BALLISTA, 1, -30.0f, 60.0f, -180.0f, 180.0f, 0.0f, 4.5f, false, 1, 20,
new Vec3(0.0, 0.0, -30.0).scale(1 / 16.0), new Vec3(0.0, 22.5, 0.0).scale(1 / 16.0), new Vec3(0.0, 0.0, 17.0).scale(1 / 16.0),
ProjectileBuilder.BALLISTA_AMMO, false,
new ItemStack[] {new ItemStack(Items.OAK_PLANKS, 2), new ItemStack(ModItems.BEAM.get(), 1), new ItemStack(Items.STICK, 5), new ItemStack(Items.IRON_NUGGET, 8)});
public static MachineType BATTERING_RAM = new MachineType(
SpecsConfig.BATTERING_RAM, 1, 0.0f, 0.0f, 0.0f, 0.0f, 0.1f, 0.1f, false, 5, 5,
new Vec3(12.0, 0.0, -48.0).scale(1 / 16.0), new Vec3(0.0, 26.0, 36.0).scale(1 / 16.0), new Vec3(0.0, 0.0, 32.0).scale(1 / 16.0),
ProjectileBuilder.NO_AMMO, false,
new ItemStack[] {new ItemStack(Items.OAK_PLANKS, 6), new ItemStack(ModItems.BEAM.get(), 8), new ItemStack(Items.STICK, 12), new ItemStack(Items.IRON_NUGGET, 8)});
public static MachineType SIEGE_LADDER = new MachineType(
SpecsConfig.SIEGE_LADDER, 1, 0.0f, 0.0f, 0.0f, 0.0f, 0.1f, 0.1f, false, 5, 5,
new Vec3(0.0, 0.0, -56.0).scale(1 / 16.0), new Vec3(0.0, 26.0, 36.0).scale(1 / 16.0), new Vec3(0.0, 0.0, 32.0).scale(1 / 16.0),
ProjectileBuilder.NO_AMMO, false,
new ItemStack[] {new ItemStack(ModItems.BEAM.get(), 4), new ItemStack(Items.STICK, 20)});
public final SiegeMachineSpecs specs;
public final int containerrows;
public final float turretminpitch;
public final float turretmaxpitch;
public final float turretminyaw;
public final float turretmaxyaw;
public final float rotationspeed;
public final float turretspeed;
public final float rotationspeed;
public final boolean yawfirst;
public final int userealisetime;
public final int usetime;
public final int delaytime;
public final Vec3 passengerpos;
public final Vec3 turretpivot;
public final Vec3 turretvector;
public final float projectilespeed;
public final float inaccuracy;
public final ProjectileBuilder[] ammo;
public final ProjectileBuilder<?>[] ammo;
public final boolean usesgunpowder;
public final ItemStack[] wreckage;
MachineType(
int health,
int rows,
SiegeMachineSpecs specs,
int containerrows,
float turretminpitch,
float turretmaxpitch,
float turretminyaw,
float turretmaxyaw,
float rotationspeed,
float turretspeed,
float rotationspeed,
boolean yawfirst,
int shootingtime,
int usetime,
int delaytime,
Vec3 passengerpos,
Vec3 turretpivot,
Vec3 turretvector,
float projectilespeed,
float inaccuracy,
ProjectileBuilder[] ammo,
boolean usesgunpowder)
ProjectileBuilder<?>[] ammo,
boolean usesgunpowder,
ItemStack[] wreckage)
{
this.health = health;
this.rows = rows;
this.specs = specs;
this.containerrows = containerrows;
this.turretminpitch = turretminpitch;
this.turretmaxpitch = turretmaxpitch;
this.turretminyaw = turretminyaw;
@ -75,13 +103,11 @@ public enum MachineType {
this.yawfirst = yawfirst;
this.userealisetime = shootingtime;
this.usetime = usetime;
this.delaytime = delaytime;
this.passengerpos = passengerpos;
this.turretpivot = turretpivot;
this.turretvector = turretvector;
this.projectilespeed = projectilespeed;
this.inaccuracy = inaccuracy;
this.ammo = ammo;
this.usesgunpowder = usesgunpowder;
this.wreckage = wreckage;
}
}

View File

@ -1,14 +1,15 @@
package ru.magistu.siegemachines.entity.machine;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.client.SoundTypes;
import ru.magistu.siegemachines.entity.IReloading;
import ru.magistu.siegemachines.gui.machine.crosshair.Crosshair;
import ru.magistu.siegemachines.gui.machine.crosshair.ReloadingCrosshair;
import ru.magistu.siegemachines.client.gui.machine.crosshair.Crosshair;
import ru.magistu.siegemachines.client.gui.machine.crosshair.ReloadingCrosshair;
import ru.magistu.siegemachines.item.ModItems;
import net.minecraft.ChatFormatting;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
@ -56,18 +57,18 @@ public class Mortar extends ShootingMachine implements IAnimatable, IReloading
event.getController().setAnimation(MOVING_ANIM);
return PlayState.CONTINUE;
}
}
@Override
public void registerControllers(AnimationData data)
public void registerControllers(AnimationData data)
{
AnimationController<?> wheels_controller = new AnimationController<>(this, "wheels_controller", 1, (t) -> {
double d = this.getWheelsSpeed();
this.wheelsspeed = d > 0 ? Math.min(d, 1.0) : Math.max(d, -1.0);
return wheelspitch += 0.013 * this.wheelsspeed;
}, this::wheels_predicate);
data.addAnimationController(wheels_controller);
}
data.addAnimationController(wheels_controller);
}
@Override
public AnimationFactory getFactory()
@ -111,21 +112,21 @@ public class Mortar extends ShootingMachine implements IAnimatable, IReloading
}
if (!this.level.isClientSide() && !this.isVehicle())
{
player.startRiding(this);
return InteractionResult.SUCCESS;
}
player.startRiding(this);
return InteractionResult.SUCCESS;
}
return InteractionResult.PASS;
return InteractionResult.PASS;
}
@Override
public void travel(Vec3 pos)
public void travel(Vec3 pos)
{
if (this.isAlive())
if (this.isAlive())
{
if (this.isVehicle())
{
LivingEntity livingentity = (LivingEntity) this.getControllingPassenger();
LivingEntity livingentity = (LivingEntity) this.getControllingPassenger();
this.setTurretRotationsDest(livingentity.getXRot(), livingentity.getYRot() - this.getYaw());
this.setYawDest(livingentity.getYRot());
@ -133,19 +134,19 @@ public class Mortar extends ShootingMachine implements IAnimatable, IReloading
this.updateYaw();
this.updateTurretRotations();
float f0 = livingentity.xxa * 0.2f;
float f1 = livingentity.zza;
if (f1 <= 0.0f)
float f0 = livingentity.xxa * 0.2f;
float f1 = livingentity.zza;
if (f1 <= 0.0f)
{
f1 *= 0.5f;
}
this.setSpeed(0.04f);
f1 *= 0.5f;
}
this.setSpeed(0.04f);
pos = new Vec3(f0, pos.y, f1);
}
}
super.travel(pos);
}
}
}
}
@Override
public void tick()
@ -153,7 +154,7 @@ public class Mortar extends ShootingMachine implements IAnimatable, IReloading
if (this.useticks != 0 && --this.useticks <= 0)
{
this.useticks = 0;
this.delayticks = this.type.delaytime;
this.delayticks = this.type.specs.delaytime.get();
}
if (this.shootingticks != 0 && --this.shootingticks <= 0)
@ -189,10 +190,15 @@ public class Mortar extends ShootingMachine implements IAnimatable, IReloading
this.renderupdateticks = SiegeMachines.RENDER_UPDATE_TIME;
}
if (this.getWheelsSpeed() > 0.0081 && this.wheelssoundticks-- <= 0)
if (this.level.isClientSide() && this.hasControllingPassenger() && this.getWheelsSpeed() > 0.0081 && this.wheelssoundticks-- <= 0)
{
this.level.playLocalSound(this.getX(), this.getY(), this.getZ(), SoundTypes.CANNON_WHEELS.get(), SoundSource.NEUTRAL, 0.3f, 1.0f, true);
this.wheelssoundticks = 20;
Entity passenger = this.getControllingPassenger();
if (Minecraft.getInstance().player == passenger)
{
Vec3 pos = this.position();
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.CANNON_WHEELS.get(), this.getSoundSource(), 1.5f, 0.85f + this.level.random.nextFloat() * 0.3f, false);
this.wheelssoundticks = 20;
}
}
super.tick();
@ -205,7 +211,7 @@ public class Mortar extends ShootingMachine implements IAnimatable, IReloading
{
if (!this.level.isClientSide())
{
this.level.playSound(null, this.getX(), this.getY(), this.getZ(), SoundTypes.FUSE.get(), SoundSource.BLOCKS, this.getVolumeFromDist(this.distanceTo(player)), 0.8f);
this.level.playSound(null, this.getX(), this.getY(), this.getZ(), SoundTypes.FUSE.get(), this.getSoundSource(), this.getVolumeFromDist(this.distanceTo(player)), 0.8f);
}
this.useticks = this.type.usetime;
this.shootingticks = this.type.userealisetime;
@ -227,7 +233,7 @@ public class Mortar extends ShootingMachine implements IAnimatable, IReloading
this.blowParticles(ParticleTypes.FLAME, 0.035, 25);
this.blowParticles(ParticleTypes.CLOUD, 0.2, 60);
Vec3 pos = this.position();
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.MORTAR_SHOOTING.get(), SoundSource.BLOCKS, 1.5f/*this.getVolumeFromDist(1.5f, 64.0f, this.distanceTo(player))*/, 0.85f + this.level.random.nextFloat() * 0.3f, false);
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.MORTAR_SHOOTING.get(), this.getSoundSource(), 0.3f, 1.0f, false);
}
}

View File

@ -0,0 +1,78 @@
package ru.magistu.siegemachines.entity.machine;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.Level;
public class Seat extends Entity
{
protected int lerpSteps;
protected double lerpX;
protected double lerpY;
protected double lerpZ;
protected double lerpYRot;
protected double lerpXRot;
public Seat(EntityType entitytype, Level level)
{
super(entitytype, level);
}
@Override
public Packet<?> getAddEntityPacket() {
return new ClientboundAddEntityPacket(this);
}
@Override
protected void defineSynchedData() {}
@Override
protected void readAdditionalSaveData(CompoundTag compound) {}
@Override
protected void addAdditionalSaveData(CompoundTag compound) {}
public boolean shouldRender(double x, double y, double z)
{
return false;
}
public boolean shouldRenderAtSqrDistance(double distance)
{
return false;
}
@Override
public void tick()
{
if (this.lerpSteps > 0)
{
double d0 = this.getX() + (this.lerpX - this.getX()) / (double) this.lerpSteps;
double d2 = this.getY() + (this.lerpY - this.getY()) / (double) this.lerpSteps;
double d4 = this.getZ() + (this.lerpZ - this.getZ()) / (double) this.lerpSteps;
double d6 = Mth.wrapDegrees(this.lerpYRot - (double) this.getYRot());
this.setYRot(this.getYRot() + (float) d6 / (float) this.lerpSteps);
this.setXRot(this.getXRot() + (float) (this.lerpXRot - (double) this.getXRot()) / (float) this.lerpSteps);
--this.lerpSteps;
this.setPos(d0, d2, d4);
this.setRot(this.getYRot(), this.getXRot());
}
super.tick();
}
@Override
public void lerpTo(double x, double y, double z, float yaw, float pitch, int posRotationIncrements, boolean teleport)
{
this.lerpX = x;
this.lerpY = y;
this.lerpZ = z;
this.lerpYRot = yaw;
this.lerpXRot = pitch;
this.lerpSteps = posRotationIncrements;
}
}

View File

@ -21,6 +21,7 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import ru.magistu.siegemachines.util.CartesianGeometry;
import java.util.Arrays;
import java.util.Random;
@ -53,13 +54,14 @@ public abstract class ShootingMachine extends Machine implements IReloading
return;
}
LivingEntity livingentity = (LivingEntity) this.getControllingPassenger();
Projectile projectile = projectilebuilder.factory.create(projectilebuilder.entitytype, this.level, new Vector3d(this.getShotPos().x, this.getShotPos().y, this.getShotPos().z), livingentity == null ? this : livingentity, projectilebuilder.projectilitem);
Vec3 shotpos = this.getShotPos();
Projectile projectile = projectilebuilder.build(this.level, new Vector3d(shotpos.x, shotpos.y, shotpos.z), livingentity == null ? this : livingentity);
if (projectile instanceof Missile)
{
Missile missile = (Missile) projectile;
missile.setItem(new ItemStack(missile.getDefaultItem()));
}
projectile.shootFromRotation(this, this.getTurretPitch(), this.getGlobalTurretYaw(), 0.0f, this.type.projectilespeed, this.type.inaccuracy);
projectile.shootFromRotation(this, this.getTurretPitch(), this.getGlobalTurretYaw(), 0.0f, this.type.specs.projectilespeed.get(), this.type.specs.inaccuracy.get());
this.level.addFreshEntity(projectile);
this.inventory.shrinkItem(projectilebuilder.item);
}
@ -110,7 +112,7 @@ public abstract class ShootingMachine extends Machine implements IReloading
double pitch = this.getTurretPitch() * Math.PI / 180.0;
double yaw = (this.getViewYRot(0.5f) + this.getTurretYaw()) * Math.PI / 180.0;
return this.position().add(applyRotations(this.type.turretpivot, 0.0, yaw).add(applyRotations(this.type.turretvector, pitch, yaw)));
return this.position().add(CartesianGeometry.applyRotations(this.type.turretpivot, 0.0, yaw).add(CartesianGeometry.applyRotations(this.type.turretvector, pitch, yaw)));
}
protected Vec3 getShotView()
@ -145,7 +147,7 @@ public abstract class ShootingMachine extends Machine implements IReloading
super.updateMachineRender();
if (!this.level.isClientSide())
{
for (int i = 0; i < rows * 9; ++i)
for (int i = 0; i < this.inventory.getContainerSize(); ++i)
{
if (this.isValidAmmo(this.inventory.getItem(i)))
{

View File

@ -0,0 +1,290 @@
package ru.magistu.siegemachines.entity.machine;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.Shapes;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.item.ModItems;
import ru.magistu.siegemachines.util.CartesianGeometry;
import software.bernie.geckolib3.core.IAnimatable;
import software.bernie.geckolib3.core.PlayState;
import software.bernie.geckolib3.core.builder.AnimationBuilder;
import software.bernie.geckolib3.core.builder.ILoopType;
import software.bernie.geckolib3.core.controller.AnimationController;
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.manager.AnimationData;
import software.bernie.geckolib3.core.manager.AnimationFactory;
import software.bernie.geckolib3.util.GeckoLibUtil;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class SiegeLadder extends Machine implements IAnimatable
{
private final AnimationFactory factory = GeckoLibUtil.createFactory(this);
private static final Vec3 CLIMB_VECTOR = new Vec3(0.0, 130.0, 130.0).scale(1.0 / 16.0);
private static final Vec3 CLIMB_PIVOT_1 = new Vec3(-8.0, 0.0, -37.0).scale(1.0 / 16.0);
private static final Vec3 CLIMB_PIVOT_2 = new Vec3(8.0, 0.0, -37.0).scale(1.0 / 16.0);
private static final int NUMBER_OF_SEATS = 16;
private final List<LadderSeat> leftseats;
private final List<LadderSeat> rightseats;
public final List<LadderSeat> seats;
static AnimationBuilder MOVING_ANIM = new AnimationBuilder().addAnimation("Moving", ILoopType.EDefaultLoopTypes.LOOP);
private int wheelssoundticks = 10;
private double wheelspitch = 0.0;
private double wheelsspeed = 0.0;
public SiegeLadder(EntityType<? extends Mob> entitytype, Level level)
{
super(entitytype, level, MachineType.SIEGE_LADDER);
this.leftseats = Stream.generate(() -> new LadderSeat(this)).limit(NUMBER_OF_SEATS / 2).collect(Collectors.toList());
this.rightseats = Stream.generate(() -> new LadderSeat(this)).limit(NUMBER_OF_SEATS / 2).collect(Collectors.toList());
this.seats = Stream.of(this.leftseats, this.rightseats)
.flatMap(Collection::stream)
.collect(Collectors.toList());
}
private <E extends IAnimatable> PlayState wheels_predicate(AnimationEvent<E> event)
{
event.getController().setAnimation(MOVING_ANIM);
return PlayState.CONTINUE;
}
@Override
public void registerControllers(AnimationData data)
{
AnimationController<?> wheels_controller = new AnimationController<>(this, "wheels_controller", 1, (t) -> {
double d = this.getWheelsSpeed();
this.wheelsspeed = d > 0 ? Math.min(d, 1.0) : Math.max(d, -1.0);
return wheelspitch += 0.015 * this.wheelsspeed;
}, this::wheels_predicate);
data.addAnimationController(wheels_controller);
}
@Override
public AnimationFactory getFactory()
{
return this.factory;
}
@Override
protected InteractionResult mobInteract(Player player, InteractionHand hand)
{
if (player.level.isClientSide() || player.isPassenger())
return InteractionResult.PASS;
if (!this.isVehicle())
{
player.startRiding(this);
return InteractionResult.SUCCESS;
}
LadderSeat seat = this.getFreeSeat(player);
if (seat != null)
{
player.startRiding(seat);
return InteractionResult.SUCCESS;
}
return InteractionResult.FAIL;
}
@Override
public void travel(Vec3 pos)
{
if (this.isAlive())
{
if (this.isVehicle())
{
LivingEntity livingentity = (LivingEntity) this.getControllingPassenger();
this.setYawDest(livingentity.getYRot());
this.updateYaw();
float f1 = livingentity.zza;
if (f1 <= 0.0f)
f1 *= 0.25f;
this.setSpeed(0.04f);
pos = new Vec3(0.0f, pos.y, f1);
}
super.travel(pos);
}
}
@Override
public void tick()
{
if (this.renderupdateticks-- <= 0)
{
this.updateMachineRender();
this.renderupdateticks = SiegeMachines.RENDER_UPDATE_TIME;
}
// if (this.getWheelsSpeed() > 0.0081 && this.wheelssoundticks-- <= 0)
// {
// this.level.playLocalSound(this.getX(), this.getY(), this.getZ(), SoundTypes.RAM_WHEELS.get(), SoundCategory.NEUTRAL, 0.6f, 1.0f, true);
// this.wheelssoundticks = 20;
// }
this.seatsTick();
super.tick();
}
public void seatsTick()
{
this.leftseats.forEach(seat -> this.updateSeatPosition(seat, true));
this.rightseats.forEach(seat -> this.updateSeatPosition(seat, false));
}
public void updateSeatPosition(LadderSeat seat, boolean left)
{
double yaw = this.getYRot() * Math.PI / 180.0;
float highness = seat.climb();
Vec3 pos = this.getSeatPosititon(highness, yaw, left);
Optional<Vec3> freepos = this.level.findFreePosition(seat, Shapes.create(AABB.ofSize(pos, 0.1, 0.1, 0.1)), pos, 0.0, 0.0, 0.0);
if (freepos.isPresent() && pos.distanceTo(freepos.get()) < 0.5)
{
seat.setHighness(highness);
pos = freepos.get();
}
else
pos = this.getSeatPosititon(seat, yaw, left);
seat.moveTo(pos);
}
@Override
public void onRemovedFromWorld()
{
for (LadderSeat seat : this.seats)
seat.discard();
super.onRemovedFromWorld();
}
@Override
public void onAddedToWorld()
{
this.seats.forEach(seat -> this.getLevel().addFreshEntity(seat));
super.onAddedToWorld();
}
@Override
public void use(Player player)
{
if (this.getControllingPassenger() == player)
{
LadderSeat seat = this.getFreeSeat(player);
if (seat != null)
player.startRiding(seat);
}
}
@Override
public void useRealise()
{
}
public double getWheelsSpeed()
{
if (this.isOnGround())
{
return this.getViewVector(5.0f).multiply(1, 0, 1).dot(this.getDeltaMovement());
}
return 0.0;
}
@Override
public Item getMachineItem()
{
return ModItems.SIEGE_LADDER.get();
}
protected Vec3 getSeatPosititon(LadderSeat seat, double yaw, boolean left)
{
return getSeatPosititon(seat.getHighness(), yaw, left);
}
protected Vec3 getSeatPosititon(float highness, double yaw, boolean left)
{
return this.position().add(CartesianGeometry.applyRotations((left ? CLIMB_PIVOT_1 : CLIMB_PIVOT_2).add(CLIMB_VECTOR.scale(highness)), 0.0, yaw));
}
protected @Nullable LadderSeat getFreeSeat(Player player)
{
AtomicReference<LadderSeat> left = new AtomicReference<>(null);
AtomicReference<LadderSeat> right = new AtomicReference<>(null);
long l1 = this.leftseats.stream().filter(seat -> {
if (seat.isVehicle())
return true;
else
{
left.set(seat);
return false;
}}).count();
long l2 = this.rightseats.stream().filter(seat -> {
if (seat.isVehicle())
return true;
else
{
right.set(seat);
return false;
}}).count();
if (l1 < l2)
return left.get();
else if (l1 == l2 && player != null)
{
Vec3 view = this.getViewVector(0.0f);
return player.position().subtract(this.position()).dot(new Vec3(view.z, 0.0, -view.x).normalize()) > 0.0 ? right.get() : left.get();
}
return right.get();
}
@Override
public void push(Entity entity)
{
}
@Override
public void push(double x, double y, double z)
{
}
}

View File

@ -2,8 +2,8 @@ package ru.magistu.siegemachines.entity.machine;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.client.SoundTypes;
import ru.magistu.siegemachines.gui.machine.crosshair.Crosshair;
import ru.magistu.siegemachines.gui.machine.crosshair.ReloadingCrosshair;
import ru.magistu.siegemachines.client.gui.machine.crosshair.Crosshair;
import ru.magistu.siegemachines.client.gui.machine.crosshair.ReloadingCrosshair;
import ru.magistu.siegemachines.item.ModItems;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
@ -18,6 +18,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import ru.magistu.siegemachines.util.CartesianGeometry;
import software.bernie.geckolib3.core.IAnimatable;
import software.bernie.geckolib3.core.PlayState;
import software.bernie.geckolib3.core.builder.AnimationBuilder;
@ -81,7 +82,7 @@ public class Trebuchet extends ShootingMachine implements IAnimatable
}
return PlayState.CONTINUE;
}
}
private void tickPart(MachinePartEntity subentity, double p_226526_2_, double p_226526_4_, double p_226526_6_)
{
@ -93,7 +94,7 @@ public class Trebuchet extends ShootingMachine implements IAnimatable
{
Vec3[] avector3d = new Vec3[this.subentities.length];
Vec3 pos = this.position().add(applyRotations(this.backsidepos, 0.0, this.getYaw()));
Vec3 pos = this.position().add(CartesianGeometry.applyRotations(this.backsidepos, 0.0, this.getYaw()));
this.tickPart(this.backside, pos.x, pos.y, pos.z);
for(int i = 0; i < this.subentities.length; ++i)
@ -103,20 +104,20 @@ public class Trebuchet extends ShootingMachine implements IAnimatable
for(int i = 0; i < this.subentities.length; ++i)
{
this.subentities[i].xo = avector3d[i].x;
this.subentities[i].yo = avector3d[i].y;
this.subentities[i].zo = avector3d[i].z;
this.subentities[i].xOld = avector3d[i].x;
this.subentities[i].yOld = avector3d[i].y;
this.subentities[i].zOld = avector3d[i].z;
this.subentities[i].xo = avector3d[i].x;
this.subentities[i].yo = avector3d[i].y;
this.subentities[i].zo = avector3d[i].z;
this.subentities[i].xOld = avector3d[i].x;
this.subentities[i].yOld = avector3d[i].y;
this.subentities[i].zOld = avector3d[i].z;
}
super.aiStep();
}
public MachinePartEntity[] getSubEntities() {
return this.subentities;
}
return this.subentities;
}
@Override
public net.minecraftforge.entity.PartEntity<?>[] getParts()
@ -125,18 +126,18 @@ public class Trebuchet extends ShootingMachine implements IAnimatable
}
@Override
public void registerControllers(AnimationData data)
public void registerControllers(AnimationData data)
{
AnimationController<?> controller = new AnimationController<>(this, "controller", 1, (t) ->
{
if (this.state.equals(State.RELOADING))
{
return (double) (this.type.delaytime - this.delayticks) / this.type.delaytime;
return (double) (this.type.specs.delaytime.get() - this.delayticks) / this.type.specs.delaytime.get();
}
return t;
}, this::predicate);
data.addAnimationController(controller);
}
data.addAnimationController(controller);
}
@Override
public AnimationFactory getFactory()
@ -155,11 +156,11 @@ public class Trebuchet extends ShootingMachine implements IAnimatable
}
if (!this.level.isClientSide() && !this.isVehicle())
{
player.startRiding(this);
return InteractionResult.SUCCESS;
}
player.startRiding(this);
return InteractionResult.SUCCESS;
}
return InteractionResult.PASS;
return InteractionResult.PASS;
}
public void startShooting(Player player)
@ -171,7 +172,7 @@ public class Trebuchet extends ShootingMachine implements IAnimatable
this.shootingticks = this.type.userealisetime;
Vec3 pos = this.position();
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.TREBUCHET_SHOOTING.get(), SoundSource.BLOCKS, 1.0f, 1.0f, false);
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.TREBUCHET_SHOOTING.get(), this.getSoundSource(), 1.0f, 1.0f, false);
}
}
@ -185,23 +186,23 @@ public class Trebuchet extends ShootingMachine implements IAnimatable
}
@Override
public void travel(Vec3 pos)
public void travel(Vec3 pos)
{
if (this.isAlive())
if (this.isAlive())
{
if (this.isVehicle() && this.useticks <= 0 && this.delayticks <= 0)
{
LivingEntity livingentity = (LivingEntity) this.getControllingPassenger();
LivingEntity livingentity = (LivingEntity) this.getControllingPassenger();
this.setTurretRotations(livingentity.getXRot(), this.getTurretYaw());
this.updateTurretRotations();
this.setYawDest(livingentity.getYRot());
this.updateYaw();
}
}
super.travel(pos);
}
}
}
}
@Override
public void tick()
@ -210,7 +211,7 @@ public class Trebuchet extends ShootingMachine implements IAnimatable
{
this.state = State.RELOADING;
this.useticks = 0;
this.delayticks = this.type.delaytime;
this.delayticks = this.type.specs.delaytime.get();
}
if (this.shootingticks != 0 && --this.shootingticks <= 0)
@ -229,7 +230,7 @@ public class Trebuchet extends ShootingMachine implements IAnimatable
if (this.delayticks % 40 == 0)
{
Vec3 pos = this.position();
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.TREBUCHET_RELOADING.get(), SoundSource.BLOCKS, 1.0f, 1.0f, false);
this.level.playLocalSound(pos.x, pos.y, pos.z, SoundTypes.TREBUCHET_RELOADING.get(), this.getSoundSource(), 1.0f, 1.0f, false);
}
if (--this.delayticks <= 0)
{

View File

@ -15,7 +15,7 @@ public class Cannonball extends Missile
this.item = ModItems.CANNONBALL.get();
}
public Cannonball(EntityType<Stone> entitytype, Level level, Vector3d pos, LivingEntity entity, Item item)
public Cannonball(EntityType<Cannonball> entitytype, Level level, Vector3d pos, LivingEntity entity, Item item)
{
super(entitytype, level, pos, entity, MissileType.CANNONBALL, item);
}

View File

@ -0,0 +1,23 @@
package ru.magistu.siegemachines.entity.projectile;
import com.mojang.math.Vector3d;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.Level;
import ru.magistu.siegemachines.item.ModItems;
public class GiantStone extends Missile
{
public GiantStone(EntityType<GiantStone> entitytype, Level level)
{
super(entitytype, level);
this.item = ModItems.GIANT_STONE.get();
}
public GiantStone(EntityType<GiantStone> entitytype, Level level, Vector3d pos, LivingEntity entity, Item item)
{
super(entitytype, level, pos, entity, MissileType.GIANT_STONE, item);
}
}

View File

@ -1,6 +1,7 @@
package ru.magistu.siegemachines.entity.projectile;
import com.mojang.math.Vector3d;
import net.minecraft.world.level.ExplosionDamageCalculator;
import ru.magistu.siegemachines.item.ModItems;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@ -32,18 +33,20 @@ import net.minecraft.world.phys.Vec3;
import net.minecraftforge.network.NetworkHooks;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
public abstract class Missile extends ThrowableItemProjectile
{
public MissileType type = MissileType.STONE;
public Item item = ModItems.STONE.get();
public Missile(EntityType<? extends Missile> entitytype, Level level)
{
{
super(entitytype, level);
}
public Missile(EntityType<? extends Missile> entitytype, Level level, Vector3d pos, LivingEntity entity, MissileType type, Item item)
{
{
super(entitytype, entity, level);
this.type = type;
this.item = item;
@ -58,20 +61,20 @@ public abstract class Missile extends ThrowableItemProjectile
@Override
public @NotNull Packet<?> getAddEntityPacket()
{
{
return NetworkHooks.getEntitySpawningPacket(this);
}
@Override
public void onHit(HitResult result)
{
{
float f = 2.0F;
if (result.getType() == HitResult.Type.ENTITY)
{
{
EntityHitResult entityRTR = (EntityHitResult)result;
Vec3 pos = entityRTR.getLocation();
Entity entity = entityRTR.getEntity();
float damage = this.type.mass * (float) this.getDeltaMovement().length();
float damage = this.type.specs.mass.get() * (float) this.getDeltaMovement().length();
DamageSource damagesource = DamageSource.thrown(this, this.getOwner());
if (this.type.armorpiercing >= 1.0f)
@ -86,12 +89,11 @@ public abstract class Missile extends ThrowableItemProjectile
}
}
damage -= (1.0f - this.type.armorpiercing) * (damage - CombatRules.getDamageAfterAbsorb(damage, 0, 0));
damagesource = damagesource.bypassArmor();
}
if (!this.level.isClientSide() && this.type.explosive)
{
this.level.explode(this.getOwner(), pos.x, pos.y, pos.z, 3.0F, Explosion.BlockInteraction.NONE);
{
this.explode(pos.x, pos.y, pos.z, 3.0F, Explosion.BlockInteraction.NONE);
this.remove(RemovalReason.KILLED);
}
@ -104,24 +106,24 @@ public abstract class Missile extends ThrowableItemProjectile
}
if (result.getType() == HitResult.Type.BLOCK)
{
{
BlockHitResult blockRTR = (BlockHitResult)result;
BlockPos blockpos = blockRTR.getBlockPos();
BlockState blockstate = this.level.getBlockState(blockpos);
boolean smoothimpact = (blockstate == Blocks.SAND.defaultBlockState() ||
blockstate == Blocks.RED_SAND.defaultBlockState() ||
blockstate == Blocks.DIRT.defaultBlockState() ||
blockstate == Blocks.GRASS_BLOCK.defaultBlockState() ||
blockstate == Blocks.DIRT_PATH.defaultBlockState() ||
blockstate == Blocks.COARSE_DIRT.defaultBlockState() ||
blockstate == Blocks.SNOW_BLOCK.defaultBlockState()) &&
blockRTR.getDirection() == Direction.UP;
blockstate == Blocks.RED_SAND.defaultBlockState() ||
blockstate == Blocks.DIRT.defaultBlockState() ||
blockstate == Blocks.GRASS_BLOCK.defaultBlockState() ||
blockstate == Blocks.DIRT_PATH.defaultBlockState() ||
blockstate == Blocks.COARSE_DIRT.defaultBlockState() ||
blockstate == Blocks.SNOW_BLOCK.defaultBlockState()) &&
blockRTR.getDirection() == Direction.UP;
if (blockRTR.getDirection() == Direction.UP)
{
{
if (this.type.explosive)
{
for (int r = 0; r < this.type.explosionradius; ++r)
for (int r = 0; r < this.type.specs.explosionpower.get(); ++r)
{
for (float a = 0; a < 2 * Math.PI; a += Math.PI / 4)
{
@ -139,30 +141,30 @@ public abstract class Missile extends ThrowableItemProjectile
if (smoothimpact && this.type.explosive)
{
this.level.explode(this.getOwner(), blockpos.getX(), blockpos.getY(), blockpos.getZ(), this.type.explosionradius * f, Explosion.BlockInteraction.NONE);
this.explode(blockpos.getX(), blockpos.getY(), blockpos.getZ(), this.type.specs.explosionpower.get() * f, Explosion.BlockInteraction.NONE);
}
}
else if (smoothimpact)
{
this.dustExplosion(new BlockParticleOption(ParticleTypes.BLOCK, blockstate).setPos(blockpos), blockpos, this.type.explosionradius / 2, 50);
this.dustExplosion(new BlockParticleOption(ParticleTypes.BLOCK, blockstate).setPos(blockpos), blockpos, this.type.specs.explosionpower.get() / 2, 50);
}
}
if (!this.level.isClientSide() && !smoothimpact && this.type.explosive)
{
this.level.explode(this.getOwner(), blockpos.getX(), blockpos.getY(), blockpos.getZ(), this.type.explosionradius * f, Explosion.BlockInteraction.BREAK);
this.explode(blockpos.getX(), blockpos.getY(), blockpos.getZ(), this.type.specs.explosionpower.get() * f, Explosion.BlockInteraction.BREAK);
}
}
if (result.getType() == HitResult.Type.MISS)
{
{
this.level.playSound((Player)this.getOwner(), this.getOnPos(), SoundEvents.ANVIL_BREAK, SoundSource.AMBIENT, 1.0f, 1.0f);
if(!this.level.isClientSide())
{
{
this.remove(RemovalReason.KILLED);
}
}
if (!this.level.isClientSide())
{
{
this.remove(RemovalReason.KILLED);
}
}
@ -173,19 +175,19 @@ public abstract class Missile extends ThrowableItemProjectile
}
private void dustExplosion(ParticleOptions particle, double x, double y, double z, double speed, int amount)
{
for (int i = 0; i < amount; ++i)
{
{
for (int i = 0; i < amount; ++i)
{
Vec3 movement = this.getDeltaMovement();
double d0 = x - 0.05 + this.level.random.nextDouble() * 0.3;
double d1 = y + 1.0;
double d2 = z - 0.05 + this.level.random.nextDouble() * 0.3;
double d3 = movement.x * this.level.random.nextDouble() * speed;
double d4 = -movement.y * this.level.random.nextDouble() * speed * 10.0f;
double d5 = movement.z * this.level.random.nextDouble() * speed;
this.level.addParticle(particle, d0, d1, d2, d3, d4, d5);
}
}
double d0 = x - 0.05 + this.level.random.nextDouble() * 0.3;
double d1 = y + 1.0;
double d2 = z - 0.05 + this.level.random.nextDouble() * 0.3;
double d3 = movement.x * this.level.random.nextDouble() * speed;
double d4 = -movement.y * this.level.random.nextDouble() * speed * 10.0f;
double d5 = movement.z * this.level.random.nextDouble() * speed;
this.level.addParticle(particle, d0, d1, d2, d3, d4, d5);
}
}
@Override
public void tick()
@ -197,4 +199,18 @@ public abstract class Missile extends ThrowableItemProjectile
super.tick();
}
public MissileExplosion explode(double x, double y, double z, float radius, Explosion.BlockInteraction mode)
{
return this.explode(null, null, x, y, z, radius, false, mode);
}
public MissileExplosion explode(@Nullable DamageSource source, @Nullable ExplosionDamageCalculator context, double x, double y, double z, float size, boolean fired, Explosion.BlockInteraction mode)
{
MissileExplosion explosion = new MissileExplosion(this.level, this.getOwner(), source, context, x, y, z, size, fired, mode);
if (net.minecraftforge.event.ForgeEventFactory.onExplosionStart(level, explosion)) return explosion;
explosion.explode();
explosion.finalizeExplosion(true);
return explosion;
}
}

View File

@ -0,0 +1,430 @@
package ru.magistu.siegemachines.entity.projectile;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.mojang.datafixers.util.Pair;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.item.PrimedTnt;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.ProtectionEnchantment;
import net.minecraft.world.level.*;
import net.minecraft.world.level.block.BaseFireBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import ru.magistu.siegemachines.entity.machine.Machine;
import javax.annotation.Nullable;
import java.util.*;
public class MissileExplosion extends Explosion
{
private static final ExplosionDamageCalculator EXPLOSION_DAMAGE_CALCULATOR = new ExplosionDamageCalculator();
private final boolean fire;
private final BlockInteraction blockInteraction;
private final Random random = new Random();
private final Level level;
private final double x;
private final double y;
private final double z;
@Nullable
private final Entity source;
private final float radius;
private final DamageSource damageSource;
private final ExplosionDamageCalculator damageCalculator;
private final List<BlockPos> toBlow = Lists.newArrayList();
private final Map<Player, Vec3> hitPlayers = Maps.newHashMap();
private final Vec3 position;
private float damagemultiplier = 1.0f;
public MissileExplosion(Level level, @Nullable Entity source, double x, double y, double z, float radius)
{
this(level, source, x, y, z, radius, false, BlockInteraction.DESTROY);
}
public MissileExplosion(Level level, @Nullable Entity source, double x, double y, double z, float radius, List<BlockPos> pPositions)
{
this(level, source, x, y, z, radius, false, BlockInteraction.DESTROY, pPositions);
}
public MissileExplosion(Level level, @Nullable Entity source, double x, double y, double z, float radius, boolean fired, BlockInteraction blockinteraction, List<BlockPos> pPositions)
{
this(level, source, x, y, z, radius, fired, blockinteraction);
this.toBlow.addAll(pPositions);
}
public MissileExplosion(Level level, @Nullable Entity source, double x, double y, double z, float radius, boolean fired, BlockInteraction blockinteraction)
{
this(level, source, null, null, x, y, z, radius, fired, blockinteraction);
}
public MissileExplosion(Level level, @Nullable Entity source, @Nullable DamageSource damagesource, @Nullable ExplosionDamageCalculator damagecalculator, double x, double y, double z, float radius, boolean fired, BlockInteraction blockinteraction)
{
super(level, source, damagesource, damagecalculator, x, y, z, radius, fired, blockinteraction);
this.level = level;
this.source = source;
this.radius = radius;
this.x = x;
this.y = y;
this.z = z;
this.fire = fired;
this.blockInteraction = blockinteraction;
this.damageSource = damagesource == null ? DamageSource.explosion(this) : damagesource;
this.damageCalculator = damagecalculator == null ? this.makeDamageCalculator(source) : damagecalculator;
this.position = new Vec3(this.x, this.y, this.z);
if (source != null && source.isPassenger())
{
Entity vehicle = source.getVehicle();
if (vehicle instanceof Machine)
{
this.damagemultiplier = ((Machine) vehicle).type.specs.damagemultiplier.get();
}
}
}
private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity pEntity)
{
return pEntity == null ? EXPLOSION_DAMAGE_CALCULATOR : new EntityBasedExplosionDamageCalculator(pEntity);
}
public static float getSeenPercent(Vec3 pExplosionVector, Entity pEntity)
{
AABB aabb = pEntity.getBoundingBox();
double d0 = 1.0D / ((aabb.maxX - aabb.minX) * 2.0D + 1.0D);
double d1 = 1.0D / ((aabb.maxY - aabb.minY) * 2.0D + 1.0D);
double d2 = 1.0D / ((aabb.maxZ - aabb.minZ) * 2.0D + 1.0D);
double d3 = (1.0D - Math.floor(1.0D / d0) * d0) / 2.0D;
double d4 = (1.0D - Math.floor(1.0D / d2) * d2) / 2.0D;
if (!(d0 < 0.0D) && !(d1 < 0.0D) && !(d2 < 0.0D))
{
int i = 0;
int j = 0;
for (double d5 = 0.0D; d5 <= 1.0D; d5 += d0)
{
for (double d6 = 0.0D; d6 <= 1.0D; d6 += d1)
{
for (double d7 = 0.0D; d7 <= 1.0D; d7 += d2)
{
double d8 = Mth.lerp(d5, aabb.minX, aabb.maxX);
double d9 = Mth.lerp(d6, aabb.minY, aabb.maxY);
double d10 = Mth.lerp(d7, aabb.minZ, aabb.maxZ);
Vec3 vec3 = new Vec3(d8 + d3, d9, d10 + d4);
if (pEntity.level.clip(new ClipContext(vec3, pExplosionVector, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, pEntity)).getType() == HitResult.Type.MISS)
{
++i;
}
++j;
}
}
}
return (float)i / (float)j;
}
else
{
return 0.0F;
}
}
/**
* Does the first part of the explosion (destroy blocks)
*/
@Override
public void explode()
{
this.level.gameEvent(this.source, GameEvent.EXPLODE, new BlockPos(this.x, this.y, this.z));
Set<BlockPos> set = Sets.newHashSet();
for (int j = 0; j < 16; ++j)
{
for (int k = 0; k < 16; ++k)
{
for (int l = 0; l < 16; ++l)
{
if (j == 0 || j == 15 || k == 0 || k == 15 || l == 0 || l == 15)
{
double d0 = (float) j / 15.0F * 2.0F - 1.0F;
double d1 = (float) k / 15.0F * 2.0F - 1.0F;
double d2 = (float) l / 15.0F * 2.0F - 1.0F;
double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
d0 /= d3;
d1 /= d3;
d2 /= d3;
float f = this.radius * (0.7F + this.level.random.nextFloat() * 0.6F);
double d4 = this.x;
double d6 = this.y;
double d8 = this.z;
for (; f > 0.0F; f -= 0.22500001F)
{
BlockPos blockpos = new BlockPos(d4, d6, d8);
BlockState blockstate = this.level.getBlockState(blockpos);
FluidState fluidstate = this.level.getFluidState(blockpos);
if (!this.level.isInWorldBounds(blockpos))
{
break;
}
Optional<Float> optional = this.damageCalculator.getBlockExplosionResistance(this, this.level, blockpos, blockstate, fluidstate);
if (optional.isPresent())
{
f -= (optional.get() + 0.3F) * 0.3F;
}
if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockpos, blockstate, f))
{
set.add(blockpos);
}
d4 += d0 * (double)0.3F;
d6 += d1 * (double)0.3F;
d8 += d2 * (double)0.3F;
}
}
}
}
}
this.toBlow.addAll(set);
float f2 = this.radius * 2.0F;
int k1 = Mth.floor(this.x - (double)f2 - 1.0D);
int l1 = Mth.floor(this.x + (double)f2 + 1.0D);
int i2 = Mth.floor(this.y - (double)f2 - 1.0D);
int i1 = Mth.floor(this.y + (double)f2 + 1.0D);
int j2 = Mth.floor(this.z - (double)f2 - 1.0D);
int j1 = Mth.floor(this.z + (double)f2 + 1.0D);
List<Entity> list = this.level.getEntities(this.source, new AABB(k1, i2, j2, l1, i1, j1));
net.minecraftforge.event.ForgeEventFactory.onExplosionDetonate(this.level, this, list, f2);
Vec3 vec3 = new Vec3(this.x, this.y, this.z);
for (Entity entity : list)
{
if (!entity.ignoreExplosion())
{
double d12 = Math.sqrt(entity.distanceToSqr(vec3)) / (double) f2;
if (d12 <= 1.0D)
{
double d5 = entity.getX() - this.x;
double d7 = (entity instanceof PrimedTnt ? entity.getY() : entity.getEyeY()) - this.y;
double d9 = entity.getZ() - this.z;
double d13 = Math.sqrt(d5 * d5 + d7 * d7 + d9 * d9);
if (d13 != 0.0D)
{
d5 /= d13;
d7 /= d13;
d9 /= d13;
double d14 = getSeenPercent(vec3, entity);
double d10 = (1.0D - d12) * d14;
entity.hurt(this.getDamageSource(), this.damagemultiplier * (int) ((d10 * d10 + d10) / 2.0D * 7.0D * (double) f2 + 1.0D));
double d11 = d10;
if (entity instanceof LivingEntity)
{
d11 = ProtectionEnchantment.getExplosionKnockbackAfterDampener((LivingEntity) entity, d10);
}
entity.setDeltaMovement(entity.getDeltaMovement().add(d5 * d11, d7 * d11, d9 * d11));
if (entity instanceof Player)
{
Player player = (Player) entity;
if (!player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying))
{
this.hitPlayers.put(player, new Vec3(d5 * d10, d7 * d10, d9 * d10));
}
}
}
}
}
}
}
/**
* Does the second part of the explosion (sound, particles, drop spawn)
*/
@Override
public void finalizeExplosion(boolean pSpawnParticles)
{
if (this.level.isClientSide)
{
this.level.playLocalSound(this.x, this.y, this.z, SoundEvents.GENERIC_EXPLODE, SoundSource.BLOCKS, 4.0F, (1.0F + (this.level.random.nextFloat() - this.level.random.nextFloat()) * 0.2F) * 0.7F, false);
}
boolean flag = this.blockInteraction != BlockInteraction.NONE;
if (pSpawnParticles)
{
if (!(this.radius < 2.0F) && flag)
{
this.level.addParticle(ParticleTypes.EXPLOSION_EMITTER, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D);
}
else
{
this.level.addParticle(ParticleTypes.EXPLOSION, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D);
}
}
if (flag)
{
ObjectArrayList<Pair<ItemStack, BlockPos>> objectarraylist = new ObjectArrayList<>();
Collections.shuffle(this.toBlow, new Random(this.level.random.nextInt()));
for (BlockPos blockpos : this.toBlow)
{
BlockState blockstate = this.level.getBlockState(blockpos);
Block block = blockstate.getBlock();
if (!blockstate.isAir())
{
BlockPos blockpos1 = blockpos.immutable();
this.level.getProfiler().push("explosion_blocks");
if (blockstate.canDropFromExplosion(this.level, blockpos, this) && this.level instanceof ServerLevel)
{
BlockEntity blockentity = blockstate.hasBlockEntity() ? this.level.getBlockEntity(blockpos) : null;
LootContext.Builder lootcontext$builder = (new LootContext.Builder((ServerLevel)this.level)).withRandom(this.level.random).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockpos)).withParameter(LootContextParams.TOOL, ItemStack.EMPTY).withOptionalParameter(LootContextParams.BLOCK_ENTITY, blockentity).withOptionalParameter(LootContextParams.THIS_ENTITY, this.source);
if (this.blockInteraction == BlockInteraction.DESTROY)
{
lootcontext$builder.withParameter(LootContextParams.EXPLOSION_RADIUS, this.radius);
}
blockstate.getDrops(lootcontext$builder).forEach((p_46074_) -> {
addBlockDrops(objectarraylist, p_46074_, blockpos1);
});
}
blockstate.onBlockExploded(this.level, blockpos, this);
this.level.getProfiler().pop();
}
}
for (Pair<ItemStack, BlockPos> pair : objectarraylist)
{
Block.popResource(this.level, pair.getSecond(), pair.getFirst());
}
}
if (this.fire)
{
for (BlockPos blockpos2 : this.toBlow)
{
if (this.random.nextInt(3) == 0 && this.level.getBlockState(blockpos2).isAir() && this.level.getBlockState(blockpos2.below()).isSolidRender(this.level, blockpos2.below()))
{
this.level.setBlockAndUpdate(blockpos2, BaseFireBlock.getState(this.level, blockpos2));
}
}
}
}
private static void addBlockDrops(ObjectArrayList<Pair<ItemStack, BlockPos>> pDropPositionArray, ItemStack pStack, BlockPos pPos)
{
int i = pDropPositionArray.size();
for (int j = 0; j < i; ++j)
{
Pair<ItemStack, BlockPos> pair = pDropPositionArray.get(j);
ItemStack itemstack = pair.getFirst();
if (ItemEntity.areMergable(itemstack, pStack))
{
ItemStack itemstack1 = ItemEntity.merge(itemstack, pStack, 16);
pDropPositionArray.set(j, Pair.of(itemstack1, pair.getSecond()));
if (pStack.isEmpty())
{
return;
}
}
}
pDropPositionArray.add(Pair.of(pStack, pPos));
}
@Override
public DamageSource getDamageSource()
{
return this.damageSource;
}
@Override
public Map<Player, Vec3> getHitPlayers()
{
return this.hitPlayers;
}
/**
* Returns either the entity that placed the explosive block, the entity that caused the explosion or null.
*/
@Nullable
@Override
public LivingEntity getSourceMob()
{
if (this.source == null)
{
return null;
}
else if (this.source instanceof PrimedTnt)
{
return ((PrimedTnt)this.source).getOwner();
}
else if (this.source instanceof LivingEntity)
{
return (LivingEntity)this.source;
}
else
{
if (this.source instanceof Projectile)
{
Entity entity = ((Projectile)this.source).getOwner();
if (entity instanceof LivingEntity)
{
return (LivingEntity)entity;
}
}
return null;
}
}
@Override
public void clearToBlow()
{
this.toBlow.clear();
}
@Override
public List<BlockPos> getToBlow()
{
return this.toBlow;
}
@Override
public Vec3 getPosition()
{
return this.position;
}
@Nullable
@Override
public Entity getExploder()
{
return this.source;
}
}

View File

@ -1,24 +1,26 @@
package ru.magistu.siegemachines.entity.projectile;
import ru.magistu.siegemachines.config.MissileSpecs;
import ru.magistu.siegemachines.config.SpecsConfig;
public enum MissileType
{
CANNONBALL(15.0f, 1.5f, true, 3.0f, FlightType.SPINNING, 1.0f),
STONE(50.0f, 1.5f, true, 3.0f, FlightType.SPINNING, 1.0f),
GIANT_ARROW(5.0f, 1.5f, false, 0.0f, FlightType.AHEAD, 0.5f);
CANNONBALL(SpecsConfig.CANNONBALL, 1.5f, true, FlightType.SPINNING, 1.0f),
STONE(SpecsConfig.STONE, 1.5f, true, FlightType.SPINNING, 1.0f),
GIANT_STONE(SpecsConfig.GIANT_STONE, 3.0f, true, FlightType.SPINNING, 1.0f);
//GIANT_ARROW(SpecsConfig.GIANT_ARROW, 1.5f, false, FlightType.AHEAD, 0.5f);
public final float mass;
public final MissileSpecs specs;
public final float knockback;
public final boolean explosive;
public final float explosionradius;
public final boolean explosive;
public final FlightType flighttype;
public final float armorpiercing;
MissileType(float mass, float knockback, boolean explosive, float explosionradius, FlightType headingtype, float armorpiercing)
MissileType(MissileSpecs specs, float knockback, boolean explosive, FlightType headingtype, float armorpiercing)
{
this.mass = mass;
this.specs = specs;
this.knockback = knockback;
this.explosive = explosive;
this.explosionradius = explosionradius;
this.flighttype = headingtype;
this.armorpiercing = armorpiercing;
}

View File

@ -1,5 +1,8 @@
package ru.magistu.siegemachines.entity.projectile;
import com.mojang.math.Vector3d;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import ru.magistu.siegemachines.entity.EntityTypes;
import ru.magistu.siegemachines.item.ModItems;
import net.minecraft.world.entity.EntityType;
@ -13,14 +16,16 @@ public class ProjectileBuilder<T extends Projectile>
{
public final static ProjectileBuilder<Stone> NONE = new ProjectileBuilder<>(Items.AIR, EntityTypes.STONE.get(), Stone::new);
public final static ProjectileBuilder[] NO_AMMO = new ProjectileBuilder[]{};
public final static ProjectileBuilder[] CANNON_AMMO = new ProjectileBuilder[]{
new ProjectileBuilder(ModItems.CANNONBALL.get(), EntityTypes.CANNONBALL.get(), Cannonball::new)};
public final static ProjectileBuilder[] THROWING_AMMO = new ProjectileBuilder[]{
new ProjectileBuilder(Items.COBBLESTONE, ModItems.STONE.get(), EntityTypes.STONE.get(), Stone::new)};
public final static ProjectileBuilder[] BALLISTA_AMMO = new ProjectileBuilder[]{
new ProjectileBuilder(ModItems.GIANT_ARROW.get(), EntityTypes.GIANT_ARROW.get(), GiantArrow::new),
new ProjectileBuilder(Items.ARROW, EntityType.ARROW, (entitytype, level, pos, entity, item) ->
public final static ProjectileBuilder<?>[] NO_AMMO = new ProjectileBuilder[]{};
public final static ProjectileBuilder<?>[] GIANT_THROWING_AMMO = new ProjectileBuilder[]{
new ProjectileBuilder<>(Items.COBBLESTONE, ModItems.GIANT_STONE.get(), EntityTypes.GIANT_STONE.get(), GiantStone::new)};
public final static ProjectileBuilder<?>[] CANNON_AMMO = new ProjectileBuilder[]{
new ProjectileBuilder<>(ModItems.CANNONBALL.get(), EntityTypes.CANNONBALL.get(), Cannonball::new)};
public final static ProjectileBuilder<?>[] THROWING_AMMO = new ProjectileBuilder[]{
new ProjectileBuilder<>(Items.COBBLESTONE, ModItems.STONE.get(), EntityTypes.STONE.get(), Stone::new)};
public final static ProjectileBuilder<?>[] BALLISTA_AMMO = new ProjectileBuilder[]{
new ProjectileBuilder<>(ModItems.GIANT_ARROW.get(), EntityTypes.GIANT_ARROW.get(), GiantArrow::new),
new ProjectileBuilder<>(Items.ARROW, EntityType.ARROW, (entitytype, level, pos, entity, item) ->
{
Arrow arrow = new Arrow(level, entity);
arrow.setPos(pos.x, pos.y, pos.z);
@ -44,6 +49,9 @@ public class ProjectileBuilder<T extends Projectile>
this.entitytype = entitytype;
this.factory = factory;
}
public T build(Level level, Vector3d pos, LivingEntity entity)
{
return this.factory.create(this.entitytype, level, pos, entity, this.item);
}
}

View File

@ -1,12 +1,13 @@
package ru.magistu.siegemachines.event;
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
import net.minecraftforge.client.event.RenderGuiOverlayEvent;
import net.minecraftforge.client.gui.overlay.VanillaGuiOverlay;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.client.KeyBindings;
import ru.magistu.siegemachines.entity.IReloading;
import ru.magistu.siegemachines.entity.machine.Machine;
import ru.magistu.siegemachines.gui.machine.crosshair.Crosshair;
import ru.magistu.siegemachines.client.gui.machine.crosshair.Crosshair;
import ru.magistu.siegemachines.network.PacketHandler;
import ru.magistu.siegemachines.network.PacketOpenMachineInventory;
import ru.magistu.siegemachines.network.PacketMachineUse;
@ -16,57 +17,76 @@ import net.minecraft.client.Options;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.InputEvent;
import net.minecraftforge.client.event.RenderGuiOverlayEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber
public class ClientEvents
{
@Mod.EventBusSubscriber(modid = SiegeMachines.ID, value = Dist.CLIENT)
public static class ClientForgeEvents
public static Crosshair CROSSHAIR = null;
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true)
@OnlyIn(Dist.CLIENT)
public static void onKeyPressedEvent(InputEvent.Key ev)
{
public static Crosshair CROSSHAIR = null;
//public static final NamedGuiOverlay CROSSHAIR_OVERLAY = GuiOverlayManager.findOverlay(VanillaGuiOverlay.CROSSHAIR.id());
@SubscribeEvent
public static void onKeyPressedEvent(InputEvent.Key ev) {
if (KeyBindings.MACHINE_USE.isDown()) {
LocalPlayer player = Minecraft.getInstance().player;
if (player != null && player.isPassenger() && player.getVehicle() instanceof Machine) {
PacketHandler.sendToServer(new PacketMachineUse(player.getVehicle().getId()));
}
}
if (KeyBindings.MACHINE_INVENTORY.isDown()) {
LocalPlayer player = Minecraft.getInstance().player;
if (player != null && player.isPassenger() && player.getVehicle() instanceof Machine) {
PacketHandler.sendToServer(new PacketOpenMachineInventory());
}
if (ev.isCanceled())
return;
if (KeyBindings.MACHINE_USE.isDown())
{
LocalPlayer player = Minecraft.getInstance().player;
if (player != null && player.isPassenger() && player.getVehicle() instanceof Machine machine && machine.usekey == KeyBindings.MACHINE_USE)
{
PacketHandler.sendToServer(new PacketMachineUse(player.getVehicle().getId()));
}
}
@SubscribeEvent
public static void onRenderOverlayPre(RenderGuiOverlayEvent.Pre ev) {
if (ev.getOverlay().id() == VanillaGuiOverlay.CROSSHAIR.id()) {
Minecraft mc = Minecraft.getInstance();
Options settings = mc.options;
LocalPlayer player = mc.player;
if (KeyBindings.LADDER_CLIMB.isDown())
{
LocalPlayer player = Minecraft.getInstance().player;
if (player != null && player.isPassenger() && player.getVehicle() instanceof Machine machine && machine.usekey == KeyBindings.LADDER_CLIMB)
{
PacketHandler.sendToServer(new PacketMachineUse(player.getVehicle().getId()));
}
}
if ((settings.renderDebug && !settings.hideGui && !player.isReducedDebugInfo() && !settings.reducedDebugInfo().get()) || settings.getCameraType().compareTo(CameraType.FIRST_PERSON) != 0) {
return;
}
if (KeyBindings.MACHINE_INVENTORY.isDown())
{
LocalPlayer player = Minecraft.getInstance().player;
if (player != null && player.isPassenger() && player.getVehicle() instanceof Machine)
{
PacketHandler.sendToServer(new PacketOpenMachineInventory());
}
}
}
if (player.isPassenger()) {
Entity entity = player.getVehicle();
if (entity instanceof IReloading) {
if (CROSSHAIR == null) {
CROSSHAIR = ((IReloading) entity).createCrosshair();
}
CROSSHAIR.render(ev.getPoseStack(), ev.getPartialTick(), mc, player);
ev.setCanceled(true);
}
@SubscribeEvent
@OnlyIn(Dist.CLIENT)
public static void onRenderOverlayPre(RenderGuiOverlayEvent.Pre ev) {
if (ev.getOverlay().id() == VanillaGuiOverlay.CROSSHAIR.id()) {
Minecraft mc = Minecraft.getInstance();
Options settings = mc.options;
LocalPlayer player = mc.player;
if ((settings.renderDebug && !settings.hideGui && !player.isReducedDebugInfo() && !settings.reducedDebugInfo().get()) || settings.getCameraType().compareTo(CameraType.FIRST_PERSON) != 0)
{
return;
}
if (player.isPassenger())
{
Entity entity = player.getVehicle();
if (entity instanceof IReloading)
{
if (CROSSHAIR == null)
CROSSHAIR = ((IReloading) entity).createCrosshair();
CROSSHAIR.render(ev.getPoseStack(), ev.getPartialTick(), mc, player);
ev.setCanceled(true);
}
}
}
@ -78,6 +98,7 @@ public class ClientEvents
@SubscribeEvent
public static void onKeyRegister(RegisterKeyMappingsEvent ev) {
ev.register(KeyBindings.MACHINE_USE);
ev.register(KeyBindings.LADDER_CLIMB);
ev.register(KeyBindings.MACHINE_INVENTORY);
}
}

View File

@ -1,6 +1,8 @@
package ru.magistu.siegemachines.event;
import net.minecraftforge.eventbus.api.EventPriority;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.config.SpecsConfig;
import ru.magistu.siegemachines.entity.EntityTypes;
import ru.magistu.siegemachines.entity.machine.*;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
@ -9,13 +11,14 @@ import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(modid = SiegeMachines.ID, bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModEventBusEvents {
@SubscribeEvent
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void addEntityAttributes(EntityAttributeCreationEvent event) {
event.put(EntityTypes.MORTAR.get(), Mortar.setEntityAttributes(MachineType.MORTAR).build());
event.put(EntityTypes.CULVERIN.get(), Mortar.setEntityAttributes(MachineType.CULVERIN).build());
event.put(EntityTypes.TREBUCHET.get(), Trebuchet.setEntityAttributes(MachineType.TREBUCHET).build());
event.put(EntityTypes.CATAPULT.get(), Catapult.setEntityAttributes(MachineType.CATAPULT).build());
event.put(EntityTypes.BALLISTA.get(), Ballista.setEntityAttributes(MachineType.BALLISTA).build());
event.put(EntityTypes.BATTERING_RAM.get(), Ballista.setEntityAttributes(MachineType.BATTERING_RAM).build());
event.put(EntityTypes.BATTERING_RAM.get(), BatteringRam.setEntityAttributes(MachineType.BATTERING_RAM).build());
event.put(EntityTypes.SIEGE_LADDER.get(), SiegeLadder.setEntityAttributes(MachineType.SIEGE_LADDER).build());
}
}

View File

@ -51,7 +51,7 @@ public class ReloadingCrosshair extends Crosshair
}
else if (machine.delayticks > 0)
{
int number = (int) (((double) animationsize) * ((double) (machine.type.delaytime - machine.delayticks) / (double) machine.type.delaytime));
int number = (int) (((double) animationsize) * ((double) (machine.type.specs.delaytime.get() - machine.delayticks) / (double) machine.type.specs.delaytime.get()));
imagex = width;
imagey = height * number;
}

View File

@ -12,8 +12,8 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.level.Level;
import ru.magistu.siegemachines.block.ModBlocks;
import ru.magistu.siegemachines.data.recipes.ModRecipes;
import ru.magistu.siegemachines.data.recipes.SiegeWorkbenchRecipe;
import ru.magistu.siegemachines.item.recipes.ModRecipes;
import ru.magistu.siegemachines.item.recipes.SiegeWorkbenchRecipe;
import ru.magistu.siegemachines.gui.ModMenuTypes;
import java.util.Optional;

View File

@ -8,13 +8,7 @@ import net.minecraft.world.inventory.RecipeHolder;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.RecipeManager;
import net.minecraft.world.item.crafting.RecipeType;
import ru.magistu.siegemachines.data.recipes.CountIngredient;
import ru.magistu.siegemachines.data.recipes.ModRecipes;
import ru.magistu.siegemachines.data.recipes.SiegeWorkbenchRecipe;
import java.util.List;
import java.util.Optional;
import ru.magistu.siegemachines.item.recipes.ModRecipes;
public class SiegeWorkbenchResultSlot extends Slot {
private final CraftingContainer craftSlots;

View File

@ -1,36 +0,0 @@
package ru.magistu.siegemachines.item;
import net.minecraft.world.entity.EntityType;
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
import ru.magistu.siegemachines.client.renderer.MachineItemGeoRenderer;
import ru.magistu.siegemachines.client.renderer.model.MachineItemModel;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import ru.magistu.siegemachines.entity.EntityTypes;
import java.util.function.Consumer;
public class BallistaItem extends MachineItem
{
public BallistaItem()
{
super(new Properties().tab(ModItems.GROUP_SM), "ballista", "BALLISTA");
}
@Override
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
super.initializeClient(consumer);
consumer.accept(new IClientItemExtensions() {
private final BlockEntityWithoutLevelRenderer renderer = new MachineItemGeoRenderer(new MachineItemModel<>("ballista"));
@Override
public BlockEntityWithoutLevelRenderer getCustomRenderer() {
return renderer;
}
});
}
@Override
public EntityType<?> getType() {
return EntityTypes.BALLISTA.get();
}
}

View File

@ -1,36 +0,0 @@
package ru.magistu.siegemachines.item;
import net.minecraft.world.entity.EntityType;
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
import ru.magistu.siegemachines.client.renderer.MachineItemGeoRenderer;
import ru.magistu.siegemachines.client.renderer.model.MachineItemModel;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import ru.magistu.siegemachines.entity.EntityTypes;
import java.util.function.Consumer;
public class BatteringRamItem extends MachineItem
{
public BatteringRamItem()
{
super(new Properties().tab(ModItems.GROUP_SM), "battering_ram", "BATTERING_RAM");
}
@Override
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
super.initializeClient(consumer);
consumer.accept(new IClientItemExtensions() {
private final BlockEntityWithoutLevelRenderer renderer = new MachineItemGeoRenderer(new MachineItemModel<>("battering_ram"));
@Override
public BlockEntityWithoutLevelRenderer getCustomRenderer() {
return renderer;
}
});
}
@Override
public EntityType<?> getType() {
return EntityTypes.BATTERING_RAM.get();
}
}

View File

@ -1,36 +0,0 @@
package ru.magistu.siegemachines.item;
import net.minecraft.world.entity.EntityType;
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
import ru.magistu.siegemachines.client.renderer.MachineItemGeoRenderer;
import ru.magistu.siegemachines.client.renderer.model.MachineItemModel;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import ru.magistu.siegemachines.entity.EntityTypes;
import java.util.function.Consumer;
public class CatapultItem extends MachineItem
{
public CatapultItem()
{
super(new Properties().tab(ModItems.GROUP_SM), "catapult", "CATAPULT");
}
@Override
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
super.initializeClient(consumer);
consumer.accept(new IClientItemExtensions() {
private final BlockEntityWithoutLevelRenderer renderer = new MachineItemGeoRenderer(new MachineItemModel<>("catapult"));
@Override
public BlockEntityWithoutLevelRenderer getCustomRenderer() {
return renderer;
}
});
}
@Override
public EntityType<?> getType() {
return EntityTypes.CATAPULT.get();
}
}

View File

@ -1,36 +0,0 @@
package ru.magistu.siegemachines.item;
import net.minecraft.world.entity.EntityType;
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
import ru.magistu.siegemachines.client.renderer.MachineItemGeoRenderer;
import ru.magistu.siegemachines.client.renderer.model.MachineItemModel;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import ru.magistu.siegemachines.entity.EntityTypes;
import java.util.function.Consumer;
public class CulverinItem extends MachineItem
{
public CulverinItem()
{
super(new Properties().tab(ModItems.GROUP_SM), "culverin", "CULVERIN");
}
@Override
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
super.initializeClient(consumer);
consumer.accept(new IClientItemExtensions() {
private final BlockEntityWithoutLevelRenderer renderer = new MachineItemGeoRenderer(new MachineItemModel<>("culverin"));
@Override
public BlockEntityWithoutLevelRenderer getCustomRenderer() {
return renderer;
}
});
}
@Override
public EntityType<?> getType() {
return EntityTypes.CULVERIN.get();
}
}

View File

@ -1,11 +1,7 @@
package ru.magistu.siegemachines.item;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.entity.EntityTypes;
import ru.magistu.siegemachines.entity.machine.Machine;
import ru.magistu.siegemachines.entity.machine.MachineType;
import ru.magistu.siegemachines.entity.projectile.ProjectileBuilder;
import net.minecraft.ChatFormatting;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
@ -32,8 +28,17 @@ import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
import net.minecraftforge.fluids.IFluidBlock;
import org.jetbrains.annotations.NotNull;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.client.KeyBindings;
import ru.magistu.siegemachines.client.renderer.MachineItemGeoRenderer;
import ru.magistu.siegemachines.entity.machine.Machine;
import ru.magistu.siegemachines.entity.machine.MachineType;
import ru.magistu.siegemachines.entity.projectile.ProjectileBuilder;
import software.bernie.geckolib3.core.IAnimatable;
import software.bernie.geckolib3.core.manager.AnimationData;
import software.bernie.geckolib3.core.manager.AnimationFactory;
@ -42,31 +47,42 @@ import software.bernie.geckolib3.util.GeckoLibUtil;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Supplier;
public abstract class MachineItem extends Item implements IAnimatable
public class MachineItem<T extends Machine> extends Item implements IAnimatable
{
private final AnimationFactory factory = GeckoLibUtil.createFactory(this);
private final String entitykey;
private final String typekey;
private final Supplier<EntityType<T>> entitytype;
private final Supplier<MachineType> machinetype;
public MachineItem(Properties prop, String entitykey, String typekey)
public MachineItem(Properties prop, Supplier<EntityType<T>> entitytype, Supplier<MachineType> machinetype)
{
super(prop.stacksTo(1));
this.entitykey = entitykey;
this.typekey = typekey;
this.entitytype = entitytype;
this.machinetype = machinetype;
}
@Override
public void appendHoverText(ItemStack p_41421_, @Nullable Level p_41422_, List<Component> tooltip, TooltipFlag p_41424_)
@OnlyIn(Dist.CLIENT)
public MachineItemGeoRenderer<T> getRenderer()
{
ProjectileBuilder[] ammo = MachineType.valueOf(this.typekey).ammo;
return null;
}
@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltip, TooltipFlag flag)
{
if (KeyBindings.getUseKey(this.machinetype.get()) != null)
tooltip.add(Component.translatable(SiegeMachines.ID + ".usage", KeyBindings.getUseKey(this.machinetype.get()).getKey().getDisplayName()).withStyle(ChatFormatting.BLUE));
ProjectileBuilder<?>[] ammo = this.machinetype.get().ammo;
if (ammo.length > 0)
{
tooltip.add(Component.translatable(SiegeMachines.ID + ".ammo").withStyle(ChatFormatting.BLUE));
for (ProjectileBuilder builder : ammo)
for (ProjectileBuilder<?> builder : ammo)
{
if (MachineType.valueOf(this.typekey).usesgunpowder)
if (this.machinetype.get().usesgunpowder)
{
tooltip.add(Component.translatable(SiegeMachines.ID + ".uses_gunpowder").withStyle(ChatFormatting.BLUE));
}
@ -76,118 +92,119 @@ public abstract class MachineItem extends Item implements IAnimatable
}
@Override
public @NotNull InteractionResult useOn(UseOnContext p_195939_1_)
{
Level world = p_195939_1_.getLevel();
if (!(world instanceof ServerLevel))
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
super.initializeClient(consumer);
consumer.accept(new IClientItemExtensions()
{
@Override
public BlockEntityWithoutLevelRenderer getCustomRenderer()
{
return MachineItem.this.getRenderer();
}
});
}
@Override
public @NotNull InteractionResult useOn(UseOnContext context)
{
Level world = context.getLevel();
if (!(world instanceof ServerLevel))
return InteractionResult.SUCCESS;
ItemStack itemstack = context.getItemInHand();
BlockPos blockpos = context.getClickedPos();
Direction direction = context.getClickedFace();
BlockState blockstate = world.getBlockState(blockpos);
if (blockstate.is(Blocks.SPAWNER))
{
BlockEntity tileentity = world.getBlockEntity(blockpos);
if (tileentity instanceof SpawnerBlockEntity)
{
BaseSpawner abstractspawner = ((SpawnerBlockEntity)tileentity).getSpawner();
EntityType<T> entitytype1 = this.getType(itemstack.getTag());
abstractspawner.setEntityId(entitytype1);
tileentity.setChanged();
world.sendBlockUpdated(blockpos, blockstate, blockstate, 3);
itemstack.shrink(1);
return InteractionResult.CONSUME;
}
}
BlockPos blockpos2;
if (blockstate.getCollisionShape(world, blockpos).isEmpty())
blockpos2 = blockpos;
else
blockpos2 = blockpos.relative(direction);
EntityType<T> entitytype = this.getType(itemstack.getTag());
Machine entity = this.spawn(entitytype, (ServerLevel) world, itemstack, context.getPlayer(), blockpos2, MobSpawnType.SPAWN_EGG, true, !Objects.equals(blockpos, blockpos2) && direction == Direction.UP, context.getRotation());
if (entity != null)
{
entity.deploymentticks = 200;
itemstack.shrink(1);
}
return InteractionResult.CONSUME;
}
protected static double getYOffset(LevelReader reader, BlockPos pos, boolean bl, AABB aabb)
{
AABB axisalignedbb = new AABB(pos);
if (bl)
axisalignedbb = axisalignedbb.expandTowards(0.0D, -1.0D, 0.0D);
Iterable<VoxelShape> iterable = reader.getCollisions(null, axisalignedbb);
return 1.0D + Shapes.collide(Direction.Axis.Y, aabb, iterable, bl ? -2.0D : -1.0D);
}
@Nullable
public Machine spawn(EntityType<T> entitytype, ServerLevel level, @Nullable ItemStack stack, @Nullable Player player, BlockPos pos, MobSpawnType type, boolean bl, boolean bl2, float yaw)
{
return this.spawn(entitytype, level, stack == null ? null : stack.getTag(), stack != null && stack.hasCustomHoverName() ? stack.getHoverName() : null, player, pos, type, bl, bl2, yaw);
}
@Nullable
public Machine spawn(EntityType<T> entitytype, ServerLevel level, @Nullable CompoundTag nbt, @Nullable Component component, @Nullable Player player, BlockPos pos, MobSpawnType type, boolean bl, boolean bl2, float yaw)
{
Machine machine = this.create(entitytype, level, nbt, component, player, pos, type, bl, bl2, yaw);
if (machine != null)
{
if (net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(machine, (LevelAccessor)level, pos.getX(), pos.getY(), pos.getZ(), null, type)) return null;
level.addFreshEntityWithPassengers(machine);
}
return machine;
}
@Nullable
public Machine create(EntityType<T> entitytype, ServerLevel level, @Nullable CompoundTag nbt, @Nullable Component component, @Nullable Player player, BlockPos pos, MobSpawnType type, boolean bl, boolean bl2, float yaw)
{
Machine machine = entitytype.create(level);
if (machine == null)
return null;
double d0;
if (bl)
{
machine.setPos((double)pos.getX() + 0.5D, pos.getY() + 1, (double)pos.getZ() + 0.5D);
d0 = getYOffset(level, pos, bl2, machine.getBoundingBox());
}
else
{
ItemStack itemstack = p_195939_1_.getItemInHand();
BlockPos blockpos = p_195939_1_.getClickedPos();
Direction direction = p_195939_1_.getClickedFace();
BlockState blockstate = world.getBlockState(blockpos);
if (blockstate.is(Blocks.SPAWNER))
{
BlockEntity tileentity = world.getBlockEntity(blockpos);
if (tileentity instanceof SpawnerBlockEntity)
{
BaseSpawner abstractspawner = ((SpawnerBlockEntity)tileentity).getSpawner();
EntityType<?> entitytype1 = this.getType(itemstack.getTag());
abstractspawner.setEntityId(entitytype1);
tileentity.setChanged();
world.sendBlockUpdated(blockpos, blockstate, blockstate, 3);
itemstack.shrink(1);
return InteractionResult.CONSUME;
}
}
d0 = 0.0D;
BlockPos blockpos1;
if (blockstate.getCollisionShape(world, blockpos).isEmpty())
{
blockpos1 = blockpos;
}
else
{
blockpos1 = blockpos.relative(direction);
}
EntityType.updateCustomEntityTag(level, player, machine, nbt);
EntityType<?> entitytype = this.getType(itemstack.getTag());
Entity entity = this.spawn(entitytype, (ServerLevel)world, itemstack, p_195939_1_.getPlayer(), blockpos1, MobSpawnType.SPAWN_EGG, true, !Objects.equals(blockpos, blockpos1) && direction == Direction.UP, p_195939_1_.getRotation());
if (component != null)
machine.setCustomName(component);
if (entity instanceof Machine)
{
((Machine)entity).deploymentticks = 200;
}
if (entity != null)
{
itemstack.shrink(1);
}
machine.moveTo((double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D, Mth.wrapDegrees(yaw), 0.0F);
machine.yHeadRot = machine.getYRot();
machine.yBodyRot = machine.getYRot();
machine.finalizeSpawn(level, level.getCurrentDifficultyAt(machine.blockPosition()), type, null, nbt);
machine.playAmbientSound();
return InteractionResult.CONSUME;
}
}
protected static double getYOffset(LevelReader p_208051_0_, BlockPos p_208051_1_, boolean p_208051_2_, AABB p_208051_3_)
{
AABB axisalignedbb = new AABB(p_208051_1_);
if (p_208051_2_)
{
axisalignedbb = axisalignedbb.expandTowards(0.0D, -1.0D, 0.0D);
}
Iterable<VoxelShape> iterable = p_208051_0_.getCollisions(null, axisalignedbb);
return 1.0D + Shapes.collide(Direction.Axis.Y, p_208051_3_, iterable, p_208051_2_ ? -2.0D : -1.0D);
}
@Nullable
public Entity spawn(EntityType<?> entitytype, ServerLevel p_220331_1_, @Nullable ItemStack p_220331_2_, @Nullable Player p_220331_3_, BlockPos p_220331_4_, MobSpawnType p_220331_5_, boolean p_220331_6_, boolean p_220331_7_, float yaw) {
return this.spawn(entitytype, p_220331_1_, p_220331_2_ == null ? null : p_220331_2_.getTag(), p_220331_2_ != null && p_220331_2_.hasCustomHoverName() ? p_220331_2_.getHoverName() : null, p_220331_3_, p_220331_4_, p_220331_5_, p_220331_6_, p_220331_7_, yaw);
}
@Nullable
public Entity spawn(EntityType<?> entitytype, ServerLevel p_20601_, @Nullable CompoundTag p_20602_, @Nullable Component p_20603_, @Nullable Player p_20604_, BlockPos p_20605_, MobSpawnType p_20606_, boolean p_20607_, boolean p_20608_, float yaw) {
Entity t = this.create(entitytype, p_20601_, p_20602_, p_20603_, p_20604_, p_20605_, p_20606_, p_20607_, p_20608_, yaw);
if (t != null)
{
if (t instanceof Mob && net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn((Mob) t, (LevelAccessor)p_20601_, p_20605_.getX(), p_20605_.getY(), p_20605_.getZ(), null, p_20606_)) return null;
p_20601_.addFreshEntityWithPassengers(t);
}
return t;
}
@Nullable
public Entity create(EntityType<?> entitytype, ServerLevel p_20656_, @Nullable CompoundTag p_20657_, @Nullable Component p_20658_, @Nullable Player p_20659_, BlockPos p_20660_, MobSpawnType p_20661_, boolean p_20662_, boolean p_20663_, float yaw)
{
Entity t = entitytype.create(p_20656_);
if (t == null) {
return null;
} else {
double d0;
if (p_20662_)
{
t.setPos((double)p_20660_.getX() + 0.5D, (double)(p_20660_.getY() + 1), (double)p_20660_.getZ() + 0.5D);
d0 = getYOffset(p_20656_, p_20660_, p_20663_, t.getBoundingBox());
}
else
{
d0 = 0.0D;
}
t.moveTo((double)p_20660_.getX() + 0.5D, (double)p_20660_.getY() + d0, (double)p_20660_.getZ() + 0.5D, Mth.wrapDegrees(yaw), 0.0F);
if (t instanceof Mob) {
Mob mobentity = (Mob)t;
mobentity.yHeadRot = mobentity.getYRot();
mobentity.yBodyRot = mobentity.getYRot();
mobentity.finalizeSpawn(p_20656_, p_20656_.getCurrentDifficultyAt(mobentity.blockPosition()), p_20661_, (SpawnGroupData)null, p_20657_);
mobentity.playAmbientSound();
}
return t;
}
return machine;
}
@Override
@ -195,64 +212,47 @@ public abstract class MachineItem extends Item implements IAnimatable
{
ItemStack itemstack = player.getItemInHand(hand);
BlockHitResult raytraceresult = getPlayerPOVHitResult(level, player, ClipContext.Fluid.SOURCE_ONLY);
if (raytraceresult.getType() != HitResult.Type.BLOCK)
{
return InteractionResultHolder.pass(itemstack);
}
else if (!(level instanceof ServerLevel))
{
if (!(level instanceof ServerLevel))
return InteractionResultHolder.success(itemstack);
}
else
BlockPos blockpos = raytraceresult.getBlockPos();
if (!(level.getBlockState(blockpos).getBlock() instanceof IFluidBlock))
return InteractionResultHolder.pass(itemstack);
if (level.mayInteract(player, blockpos) && player.mayUseItemAt(blockpos, raytraceresult.getDirection(), itemstack))
{
BlockPos blockpos = raytraceresult.getBlockPos();
if (!(level.getBlockState(blockpos).getBlock() instanceof IFluidBlock))
EntityType<T> entitytype = this.getType(itemstack.getTag());
Machine machine = this.spawn(entitytype, (ServerLevel) level, itemstack, player, blockpos, MobSpawnType.SPAWN_EGG, false, false, player.getYRot());
if (machine != null)
{
return InteractionResultHolder.pass(itemstack);
}
else if (level.mayInteract(player, blockpos) && player.mayUseItemAt(blockpos, raytraceresult.getDirection(), itemstack))
{
EntityType<?> entitytype = this.getType(itemstack.getTag());
Entity entity = this.spawn(entitytype, (ServerLevel) level, itemstack, player, blockpos, MobSpawnType.SPAWN_EGG, false, false, player.getYRot());
if (entity instanceof Machine)
{
((Machine)entity).deploymentticks = 200;
}
if (entity != null)
{
if (!player.isCreative())
{
itemstack.shrink(1);
}
player.awardStat(Stats.ITEM_USED.get(this));
return InteractionResultHolder.consume(itemstack);
}
else
{
return InteractionResultHolder.pass(itemstack);
}
machine.deploymentticks = 200;
if (!player.isCreative())
itemstack.shrink(1);
player.awardStat(Stats.ITEM_USED.get(this));
return InteractionResultHolder.consume(itemstack);
}
else
{
return InteractionResultHolder.fail(itemstack);
}
return InteractionResultHolder.pass(itemstack);
}
else
return InteractionResultHolder.fail(itemstack);
}
public abstract EntityType<?> getType();
public EntityType<?> getType(@Nullable CompoundTag nbt)
@SuppressWarnings("unchecked")
public EntityType<T> getType(@Nullable CompoundTag nbt)
{
EntityType<?> defaulttype = this.getType();
EntityType<T> defaulttype = this.entitytype.get();
if (nbt != null && nbt.contains("EntityTag", 10))
{
CompoundTag compoundnbt = nbt.getCompound("EntityTag");
if (compoundnbt.contains("id", 8))
{
return EntityType.byString(compoundnbt.getString("id")).orElse(defaulttype);
}
return (EntityType<T>) EntityType.byString(compoundnbt.getString("id")).orElse(defaulttype);
}
return defaulttype;

View File

@ -1,14 +1,20 @@
package ru.magistu.siegemachines.item;
import ru.magistu.siegemachines.SiegeMachines;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.client.renderer.*;
import ru.magistu.siegemachines.client.renderer.model.MachineItemModel;
import ru.magistu.siegemachines.entity.EntityTypes;
import ru.magistu.siegemachines.entity.machine.*;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public class ModItems
@ -22,15 +28,24 @@ public class ModItems
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, SiegeMachines.ID);
public static final RegistryObject<MachineItem> MORTAR = ITEMS.register("mortar", MortarItem::new);
//public static final RegistryObject<MachineItem> CULVERIN = ITEMS.register("culverin", CulverinItem::new);
public static final RegistryObject<MachineItem> CATAPULT = ITEMS.register("catapult", CatapultItem::new);
public static final RegistryObject<MachineItem> TREBUCHET = ITEMS.register("trebuchet", TrebuchetItem::new);
public static final RegistryObject<MachineItem> BALLISTA = ITEMS.register("ballista", BallistaItem::new);
public static final RegistryObject<MachineItem> BATTERING_RAM = ITEMS.register("battering_ram", BatteringRamItem::new);
public static final RegistryObject<Item> MORTAR = ITEMS.register("mortar", () -> new MachineItem<>(new Item.Properties().tab(ModItems.GROUP_SM), EntityTypes.MORTAR, () -> MachineType.MORTAR)
{@Override @OnlyIn(Dist.CLIENT) public MachineItemGeoRenderer<Mortar> getRenderer() {return new MachineItemGeoRenderer<>(new MachineItemModel<>("mortar"));}});
public static final RegistryObject<Item> CULVERIN = ITEMS.register("culverin", () -> new MachineItem<>(new Item.Properties().tab(ModItems.GROUP_SM), EntityTypes.CULVERIN, () -> MachineType.CULVERIN)
{@Override @OnlyIn(Dist.CLIENT) public MachineItemGeoRenderer<Culverin> getRenderer() {return new MachineItemGeoRenderer<>(new MachineItemModel<>("culverin"));}});
public static final RegistryObject<Item> CATAPULT = ITEMS.register("catapult", () -> new MachineItem<>(new Item.Properties().tab(ModItems.GROUP_SM), EntityTypes.CATAPULT, () -> MachineType.CATAPULT)
{@Override @OnlyIn(Dist.CLIENT) public MachineItemGeoRenderer<Catapult> getRenderer() {return new MachineItemGeoRenderer<>(new MachineItemModel<>("catapult"));}});
public static final RegistryObject<Item> TREBUCHET = ITEMS.register("trebuchet", () -> new MachineItem<>(new Item.Properties().tab(ModItems.GROUP_SM), EntityTypes.TREBUCHET, () -> MachineType.TREBUCHET)
{@Override @OnlyIn(Dist.CLIENT) public MachineItemGeoRenderer<Trebuchet> getRenderer() {return new MachineItemGeoRenderer<>(new MachineItemModel<>("trebuchet"));}});
public static final RegistryObject<Item> BALLISTA = ITEMS.register("ballista", () -> new MachineItem<>(new Item.Properties().tab(ModItems.GROUP_SM), EntityTypes.BALLISTA, () -> MachineType.BALLISTA)
{@Override @OnlyIn(Dist.CLIENT) public MachineItemGeoRenderer<Ballista> getRenderer() {return new MachineItemGeoRenderer<>(new MachineItemModel<>("ballista"));}});
public static final RegistryObject<Item> BATTERING_RAM = ITEMS.register("battering_ram", () -> new MachineItem<>(new Item.Properties().tab(ModItems.GROUP_SM), EntityTypes.BATTERING_RAM, () -> MachineType.BATTERING_RAM)
{@Override @OnlyIn(Dist.CLIENT) public MachineItemGeoRenderer<BatteringRam> getRenderer() {return new MachineItemGeoRenderer<>(new MachineItemModel<>("battering_ram"));}});
public static final RegistryObject<Item> SIEGE_LADDER = ITEMS.register("siege_ladder", () -> new MachineItem<>(new Item.Properties().tab(ModItems.GROUP_SM), EntityTypes.SIEGE_LADDER, () -> MachineType.SIEGE_LADDER)
{@Override @OnlyIn(Dist.CLIENT) public MachineItemGeoRenderer<SiegeLadder> getRenderer() {return new MachineItemGeoRenderer<>(new MachineItemModel<>("siege_ladder"));}});
public static final RegistryObject<Item> CANNONBALL = ITEMS.register("cannonball", () -> new Item(new Item.Properties().stacksTo(16).tab(ModItems.GROUP_SM)));
public static final RegistryObject<Item> STONE = ITEMS.register("stone", () -> new Item(new Item.Properties().stacksTo(16)));
public static final RegistryObject<Item> GIANT_STONE = ITEMS.register("giant_stone", () -> new Item(new Item.Properties().stacksTo(16)));
public static final RegistryObject<Item> GIANT_ARROW = ITEMS.register("giant_arrow", () -> new Item(new Item.Properties().stacksTo(16).tab(ModItems.GROUP_SM)));
public static final RegistryObject<Item> TURRET_BASE = ITEMS.register("turret_base", () -> new Item(new Item.Properties().tab(ModItems.GROUP_SM)));

View File

@ -1,36 +0,0 @@
package ru.magistu.siegemachines.item;
import net.minecraft.world.entity.EntityType;
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
import ru.magistu.siegemachines.client.renderer.MachineItemGeoRenderer;
import ru.magistu.siegemachines.client.renderer.model.MachineItemModel;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import ru.magistu.siegemachines.entity.EntityTypes;
import java.util.function.Consumer;
public class MortarItem extends MachineItem
{
public MortarItem()
{
super(new Properties().tab(ModItems.GROUP_SM), "mortar", "MORTAR");
}
@Override
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
super.initializeClient(consumer);
consumer.accept(new IClientItemExtensions() {
private final BlockEntityWithoutLevelRenderer renderer = new MachineItemGeoRenderer(new MachineItemModel<>("mortar"));
@Override
public BlockEntityWithoutLevelRenderer getCustomRenderer() {
return renderer;
}
});
}
@Override
public EntityType<?> getType() {
return EntityTypes.MORTAR.get();
}
}

View File

@ -1,36 +0,0 @@
package ru.magistu.siegemachines.item;
import net.minecraft.world.entity.EntityType;
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
import ru.magistu.siegemachines.client.renderer.MachineItemGeoRenderer;
import ru.magistu.siegemachines.client.renderer.model.MachineItemModel;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import ru.magistu.siegemachines.entity.EntityTypes;
import java.util.function.Consumer;
public class TrebuchetItem extends MachineItem
{
public TrebuchetItem()
{
super(new Properties().tab(ModItems.GROUP_SM), "trebuchet", "TREBUCHET");
}
@Override
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
super.initializeClient(consumer);
consumer.accept(new IClientItemExtensions() {
private final BlockEntityWithoutLevelRenderer renderer = new MachineItemGeoRenderer(new MachineItemModel<>("trebuchet"));
@Override
public BlockEntityWithoutLevelRenderer getCustomRenderer() {
return renderer;
}
});
}
@Override
public EntityType<?> getType() {
return EntityTypes.TREBUCHET.get();
}
}

View File

@ -1,4 +1,4 @@
package ru.magistu.siegemachines.data.recipes;
package ru.magistu.siegemachines.item.recipes;
import java.util.Arrays;
import java.util.List;

View File

@ -1,4 +1,4 @@
package ru.magistu.siegemachines.data.recipes;
package ru.magistu.siegemachines.item.recipes;
import net.minecraft.world.item.crafting.RecipeType;
import ru.magistu.siegemachines.SiegeMachines;

View File

@ -1,4 +1,4 @@
package ru.magistu.siegemachines.data.recipes;
package ru.magistu.siegemachines.item.recipes;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Maps;
@ -19,8 +19,6 @@ import net.minecraft.world.item.crafting.*;
import net.minecraft.world.level.Level;
import ru.magistu.siegemachines.block.ModBlocks;
import javax.annotation.Nullable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

View File

@ -9,8 +9,8 @@ import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.crafting.RecipeManager;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.data.recipes.ModRecipes;
import ru.magistu.siegemachines.data.recipes.SiegeWorkbenchRecipe;
import ru.magistu.siegemachines.item.recipes.ModRecipes;
import ru.magistu.siegemachines.item.recipes.SiegeWorkbenchRecipe;
import java.util.List;
import java.util.Objects;

View File

@ -1,6 +1,5 @@
package ru.magistu.siegemachines.plugins.jei;
import com.mojang.datafixers.kinds.IdF;
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.drawable.IDrawable;
@ -10,16 +9,15 @@ import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.RecipeType;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;
import ru.magistu.siegemachines.SiegeMachines;
import ru.magistu.siegemachines.block.ModBlocks;
import ru.magistu.siegemachines.data.recipes.ModRecipes;
import ru.magistu.siegemachines.data.recipes.SiegeWorkbenchRecipe;
import ru.magistu.siegemachines.item.recipes.CountIngredient;
import ru.magistu.siegemachines.item.recipes.SiegeWorkbenchRecipe;
import javax.annotation.Nonnull;
import java.util.List;
public class SiegeWorkbenchRecipeCategory implements IRecipeCategory<SiegeWorkbenchRecipe> {
public final static ResourceLocation TEXTURE = new ResourceLocation(SiegeMachines.ID, "textures/gui/siege_workbench.png");
@ -33,27 +31,23 @@ public class SiegeWorkbenchRecipeCategory implements IRecipeCategory<SiegeWorkbe
this.background = helper.createDrawable(TEXTURE, 29, 16, 116, 54);
this.icon = helper.createDrawableIngredient(VanillaTypes.ITEM_STACK, new ItemStack(ModBlocks.SIEGE_WORKBENCH.get()));
}
@Override
@NotNull
public RecipeType<SiegeWorkbenchRecipe> getRecipeType() {
return RECIPE_TYPE;
}
@Override
@NotNull
public Component getTitle() {
return Component.translatable("category." + SiegeMachines.ID + ".siege_workbench_crafting");
}
@Override
@NotNull
public IDrawable getBackground() {
return this.background;
}
@Override
@NotNull
public IDrawable getIcon() {
return this.icon;
}
@ -62,13 +56,12 @@ public class SiegeWorkbenchRecipeCategory implements IRecipeCategory<SiegeWorkbe
public void setRecipe(@Nonnull IRecipeLayoutBuilder builder, @Nonnull SiegeWorkbenchRecipe recipe, @Nonnull IFocusGroup focusGroup)
{
builder.addSlot(RecipeIngredientRole.OUTPUT, 94, 18).addItemStack(recipe.getResultItem());
List<CountIngredient> grid = recipe.getRecipeItems();
for (int i = 0; i < recipe.getWidth(); ++i)
{
for (int j = 0; j < recipe.getHeight(); ++j)
{
builder.addSlot(RecipeIngredientRole.INPUT, j * 18, i * 18).addItemStacks(recipe.getRecipeItems().get(j + recipe.getWidth() * i).getCountModifiedItemStacks());
}
builder.addSlot(RecipeIngredientRole.INPUT, i * 18, j * 18).addItemStacks(grid.get(i + j * 3).getCountModifiedItemStacks());
}
}
}

View File

@ -0,0 +1,13 @@
package ru.magistu.siegemachines.util;
import net.minecraft.world.phys.Vec3;
public class CartesianGeometry
{
public static Vec3 applyRotations(Vec3 vec, double pitch, double yaw) {
double x = vec.x * Math.cos(yaw) - vec.y * Math.sin(pitch) * Math.sin(yaw) - vec.z * Math.sin(yaw) * Math.cos(pitch);
double y = vec.y * Math.cos(pitch) - vec.z * Math.sin(pitch);
double z = vec.x * Math.sin(yaw) + vec.y * Math.sin(pitch) * Math.cos(yaw) + vec.z * Math.cos(yaw) * Math.cos(pitch);
return new Vec3(x, y, z);
}
}

View File

@ -3,7 +3,7 @@ loaderVersion="[41,)" #mandatory
license="All rights reserved"
[[mods]] #mandatory
modId="siegemachines" #mandatory
version="${file.jarVersion}" #mandatory
version="${version}" #mandatory
# A display name for the mod
displayName="Medieval Siege Machines" #mandatory
# logoFile="siegemachines.png" #optional // TODO Logo

View File

@ -67,25 +67,16 @@
}
}
},
"TurningRight": {
"Turning": {
"loop": true,
"animation_length": 2,
"animation_length": 4,
"bones": {
"Wheel1": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [90, 0, 0]
},
"1.0": {
"vector": [180, 0, 0]
},
"1.5": {
"vector": [270, 0, 0]
},
"2.0": {
"4.0": {
"vector": [360, 0, 0]
}
}
@ -95,16 +86,7 @@
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [90, 0, 0]
},
"1.0": {
"vector": [180, 0, 0]
},
"1.5": {
"vector": [270, 0, 0]
},
"2.0": {
"4.0": {
"vector": [360, 0, 0]
}
}
@ -114,16 +96,7 @@
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [90, 0, 0]
},
"1.0": {
"vector": [180, 0, 0]
},
"1.5": {
"vector": [270, 0, 0]
},
"2.0": {
"4.0": {
"vector": [360, 0, 0]
}
}
@ -133,16 +106,7 @@
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [-90, 0, 0]
},
"1.0": {
"vector": [-180, 0, 0]
},
"1.5": {
"vector": [-270, 0, 0]
},
"2.0": {
"4.0": {
"vector": [-360, 0, 0]
}
}
@ -152,16 +116,7 @@
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [-90, 0, 0]
},
"1.0": {
"vector": [-180, 0, 0]
},
"1.5": {
"vector": [-270, 0, 0]
},
"2.0": {
"4.0": {
"vector": [-360, 0, 0]
}
}
@ -171,142 +126,13 @@
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [-90, 0, 0]
},
"1.0": {
"vector": [-180, 0, 0]
},
"1.5": {
"vector": [-270, 0, 0]
},
"2.0": {
"4.0": {
"vector": [-360, 0, 0]
}
}
}
}
},
"TurningLeft": {
"loop": true,
"animation_length": 2,
"bones": {
"Wheel1": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [-90, 0, 0]
},
"1.0": {
"vector": [-180, 0, 0]
},
"1.5": {
"vector": [-270, 0, 0]
},
"2.0": {
"vector": [-360, 0, 0]
}
}
},
"Wheel2": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [-90, 0, 0]
},
"1.0": {
"vector": [-180, 0, 0]
},
"1.5": {
"vector": [-270, 0, 0]
},
"2.0": {
"vector": [-360, 0, 0]
}
}
},
"Wheel3": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [-90, 0, 0]
},
"1.0": {
"vector": [-180, 0, 0]
},
"1.5": {
"vector": [-270, 0, 0]
},
"2.0": {
"vector": [-360, 0, 0]
}
}
},
"Wheel4": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [90, 0, 0]
},
"1.0": {
"vector": [180, 0, 0]
},
"1.5": {
"vector": [270, 0, 0]
},
"2.0": {
"vector": [360, 0, 0]
}
}
},
"Wheel5": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [90, 0, 0]
},
"1.0": {
"vector": [180, 0, 0]
},
"1.5": {
"vector": [270, 0, 0]
},
"2.0": {
"vector": [360, 0, 0]
}
}
},
"Wheel6": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"0.5": {
"vector": [90, 0, 0]
},
"1.0": {
"vector": [180, 0, 0]
},
"1.5": {
"vector": [270, 0, 0]
},
"2.0": {
"vector": [360, 0, 0]
}
}
}
}
},
"Reloading": {
"animation_length": 5,
"bones": {

View File

@ -0,0 +1,32 @@
{
"format_version": "1.8.0",
"animations": {
"Moving": {
"loop": true,
"animation_length": 4,
"bones": {
"Wheel1": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [0, 0, 360]
}
}
},
"Wheel2": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [0, 0, 360]
}
}
}
}
}
},
"geckolib_format_version": 2
}

View File

@ -1,22 +1,6 @@
{
"format_version": "1.8.0",
"animations": {
"Tilting": {
"loop": true,
"animation_length": 4,
"bones": {
"Barrel": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [360, 0, 0]
}
}
}
}
},
"Moving": {
"loop": true,
"animation_length": 4,

View File

@ -0,0 +1,138 @@
{
"format_version": "1.8.0",
"animations": {
"Moving": {
"loop": true,
"animation_length": 4,
"bones": {
"Wheel1": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [360, 0, 0]
}
}
},
"Wheel2": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [360, 0, 0]
}
}
},
"Wheel3": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [360, 0, 0]
}
}
},
"Wheel4": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [360, 0, 0]
}
}
},
"Wheel5": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [360, 0, 0]
}
}
},
"Wheel6": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [360, 0, 0]
}
}
}
}
},
"Turning": {
"loop": true,
"animation_length": 4,
"bones": {
"Wheel1": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [360, 0, 0]
}
}
},
"Wheel2": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [360, 0, 0]
}
}
},
"Wheel3": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [360, 0, 0]
}
}
},
"Wheel4": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [-360, 0, 0]
}
}
},
"Wheel5": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [-360, 0, 0]
}
}
},
"Wheel6": {
"rotation": {
"0.0": {
"vector": [0, 0, 0]
},
"4.0": {
"vector": [-360, 0, 0]
}
}
}
}
}
},
"geckolib_format_version": 2
}

View File

@ -22,7 +22,7 @@
"name": "Structure",
"pivot": [0, 4.18198, -8.1],
"cubes": [
{"origin": [-1.5, 0, -1.4], "size": [3, 20, 3], "uv": [44, 0]},
{"origin": [-1.5, 0, -1.4], "size": [3, 13, 3], "uv": [44, 0]},
{"origin": [-8.90381, 1.28198, -4.4], "size": [1, 2, 11], "pivot": [-7.40381, 4.28198, -0.9], "rotation": [0, 90, -45], "uv": [0, 0]},
{"origin": [-0.5, -0.81802, 0.83223], "size": [1, 2, 11], "pivot": [-4, 4.18198, 10.33223], "rotation": [-45, 0, 0], "uv": [0, 39]},
{"origin": [-1.5, -1, -11.9], "size": [3, 2, 24], "uv": [44, 0]},
@ -35,24 +35,24 @@
"name": "Balliste",
"pivot": [0, 20, 0],
"cubes": [
{"origin": [-2.4, 20, -1.9], "size": [5, 1, 4], "uv": [12, 52]},
{"origin": [-0.4, 19.8, -0.4], "size": [1, 2, 1], "uv": [0, 5]},
{"origin": [2, 20.3, -1.4], "size": [1, 4, 3], "uv": [13, 13]},
{"origin": [-2.8, 20.3, -1.4], "size": [1, 4, 3], "uv": [0, 13]},
{"origin": [-2.9, 16.3, -7.3], "size": [2, 13, 1], "uv": [31, 0]},
{"origin": [-5.9, 17.3, -7.3], "size": [2, 11, 1], "pivot": [-4.9, 22.8, -6.8], "rotation": [0, 45, 0], "uv": [55, 53]},
{"origin": [1.1, 16.3, -7.3], "size": [2, 13, 1], "uv": [31, 14]},
{"origin": [4.1, 17.3, -7.3], "size": [2, 11, 1], "pivot": [5.1, 22.8, -6.8], "rotation": [0, -45, 0], "uv": [23, 12]},
{"origin": [-5.9, 26.3, -7.6], "size": [12, 1, 1], "uv": [0, 33]},
{"origin": [-5.9, 18.3, -7.6], "size": [12, 1, 1], "uv": [0, 26]},
{"origin": [-1.4, 21.5, -12.4], "size": [3, 1, 38], "uv": [0, 0]},
{"origin": [0.7, 20.4, 17.6], "size": [1, 2, 10], "uv": [33, 53]},
{"origin": [-1.9, 21.4, 26.1], "size": [4, 2, 1], "uv": [0, 8]},
{"origin": [-1.5, 20.4, 17.6], "size": [1, 2, 10], "uv": [0, 52]},
{"origin": [0.8, 22, -12.5], "size": [1, 1, 31], "uv": [33, 40]},
{"origin": [0.8, 22, 18.5], "size": [1, 1, 8], "uv": [46, 40]},
{"origin": [-1.6, 22, 18.5], "size": [1, 1, 8], "uv": [13, 39]},
{"origin": [-1.6, 22, -12.5], "size": [1, 1, 31], "uv": [0, 39]}
{"origin": [-2.4, 12, -1.9], "size": [5, 1, 4], "uv": [12, 52]},
{"origin": [-0.4, 11.8, -0.4], "size": [1, 2, 1], "uv": [0, 5]},
{"origin": [2, 12.3, -1.4], "size": [1, 4, 3], "uv": [13, 13]},
{"origin": [-2.8, 12.3, -1.4], "size": [1, 4, 3], "uv": [0, 13]},
{"origin": [-2.9, 8.3, -7.3], "size": [2, 13, 1], "uv": [31, 0]},
{"origin": [-5.9, 9.3, -7.3], "size": [2, 11, 1], "pivot": [-4.9, 22.8, -6.8], "rotation": [0, 45, 0], "uv": [55, 53]},
{"origin": [1.1, 8.3, -7.3], "size": [2, 13, 1], "uv": [31, 14]},
{"origin": [4.1, 9.3, -7.3], "size": [2, 11, 1], "pivot": [5.1, 22.8, -6.8], "rotation": [0, -45, 0], "uv": [23, 12]},
{"origin": [-5.9, 18.3, -7.6], "size": [12, 1, 1], "uv": [0, 33]},
{"origin": [-5.9, 10.3, -7.6], "size": [12, 1, 1], "uv": [0, 26]},
{"origin": [-1.4, 13.5, -12.4], "size": [3, 1, 38], "uv": [0, 0]},
{"origin": [0.7, 12.4, 17.6], "size": [1, 2, 10], "uv": [33, 53]},
{"origin": [-1.9, 13.4, 26.1], "size": [4, 2, 1], "uv": [0, 8]},
{"origin": [-1.5, 12.4, 17.6], "size": [1, 2, 10], "uv": [0, 52]},
{"origin": [0.8, 14, -12.5], "size": [1, 1, 31], "uv": [33, 40]},
{"origin": [0.8, 14, 18.5], "size": [1, 1, 8], "uv": [46, 40]},
{"origin": [-1.6, 14, 18.5], "size": [1, 1, 8], "uv": [13, 39]},
{"origin": [-1.6, 14, -12.5], "size": [1, 1, 31], "uv": [0, 39]}
]
},
{
@ -60,8 +60,8 @@
"parent": "Balliste",
"pivot": [-1.07597, 23.3, -6.48107],
"cubes": [
{"origin": [-11.1, 22, -5.9], "size": [10, 2, 1], "pivot": [-5.1, 23, -6.4], "rotation": [0, 20, 0], "uv": [0, 35]},
{"origin": [-19.07597, 22.5, -0.78107], "size": [10, 1, 1], "pivot": [-14.07597, 23, -0.28107], "rotation": [0, 40, 0], "uv": [44, 35]}
{"origin": [-11.1, 14, -5.9], "size": [10, 2, 1], "pivot": [-5.1, 23, -6.4], "rotation": [0, 20, 0], "uv": [0, 35]},
{"origin": [-19.07597, 14.5, -0.78107], "size": [10, 1, 1], "pivot": [-14.07597, 23, -0.28107], "rotation": [0, 40, 0], "uv": [44, 35]}
]
},
{
@ -69,26 +69,26 @@
"parent": "Balliste",
"pivot": [1.07597, 23.3, -6.48107],
"cubes": [
{"origin": [1.1, 22, -5.9], "size": [10, 2, 1], "pivot": [5.1, 23, -6.4], "rotation": [0, -20, 0], "uv": [44, 32]},
{"origin": [9.07597, 22.5, -0.78107], "size": [10, 1, 1], "pivot": [14.07597, 23, -0.28107], "rotation": [0, -40, 0], "uv": [0, 64]}
{"origin": [1.1, 14, -5.9], "size": [10, 2, 1], "pivot": [5.1, 23, -6.4], "rotation": [0, -20, 0], "uv": [44, 32]},
{"origin": [9.07597, 14.5, -0.78107], "size": [10, 1, 1], "pivot": [14.07597, 23, -0.28107], "rotation": [0, -40, 0], "uv": [0, 64]}
]
},
{
"name": "Manivelles",
"parent": "Balliste",
"pivot": [0.14545, 21.9, 24.6],
"pivot": [0.14545, 13.9, 24.6],
"cubes": [
{"origin": [-2.9, 21.4, 24.1], "size": [6, 1, 1], "uv": [13, 8]},
{"origin": [-3.7, 13.4, 28.1], "size": [1, 4, 1], "pivot": [-3.2, 21.9, 28.6], "rotation": [-90, 0, 0], "uv": [0, 39]},
{"origin": [-4.1, 20.9, 23.6], "size": [1, 2, 2], "uv": [21, 0]},
{"origin": [-3.7, 22.4, 24.1], "size": [1, 4, 1], "uv": [17, 39]},
{"origin": [-3.7, 17.4, 24.1], "size": [1, 4, 1], "uv": [13, 39]},
{"origin": [-3.7, 18.4, 28.1], "size": [1, 4, 1], "pivot": [-3.2, 21.9, 28.6], "rotation": [-90, 0, 0], "uv": [4, 39]},
{"origin": [3, 13.4, 28.1], "size": [1, 4, 1], "pivot": [3.5, 21.9, 28.6], "rotation": [-90, 0, 0], "uv": [30, 33]},
{"origin": [3.4, 20.9, 23.6], "size": [1, 2, 2], "uv": [13, 20]},
{"origin": [3, 18.4, 28.1], "size": [1, 4, 1], "pivot": [3.5, 21.9, 28.6], "rotation": [-90, 0, 0], "uv": [34, 33]},
{"origin": [3, 17.4, 24.1], "size": [1, 4, 1], "uv": [0, 0]},
{"origin": [3, 22.4, 24.1], "size": [1, 4, 1], "uv": [26, 33]}
{"origin": [-2.9, 13.4, 24.1], "size": [6, 1, 1], "uv": [13, 8]},
{"origin": [-3.7, 13.4, 36.1], "size": [1, 4, 1], "pivot": [-3.2, 21.9, 28.6], "rotation": [-90, 0, 0], "uv": [0, 39]},
{"origin": [-4.1, 12.9, 23.6], "size": [1, 2, 2], "uv": [21, 0]},
{"origin": [-3.7, 14.4, 24.1], "size": [1, 4, 1], "uv": [17, 39]},
{"origin": [-3.7, 9.4, 24.1], "size": [1, 4, 1], "uv": [13, 39]},
{"origin": [-3.7, 18.4, 36.1], "size": [1, 4, 1], "pivot": [-3.2, 21.9, 28.6], "rotation": [-90, 0, 0], "uv": [4, 39]},
{"origin": [3, 13.4, 36.1], "size": [1, 4, 1], "pivot": [3.5, 21.9, 28.6], "rotation": [-90, 0, 0], "uv": [30, 33]},
{"origin": [3.4, 12.9, 23.6], "size": [1, 2, 2], "uv": [13, 20]},
{"origin": [3, 18.4, 36.1], "size": [1, 4, 1], "pivot": [3.5, 21.9, 28.6], "rotation": [-90, 0, 0], "uv": [34, 33]},
{"origin": [3, 9.4, 24.1], "size": [1, 4, 1], "uv": [0, 0]},
{"origin": [3, 14.4, 24.1], "size": [1, 4, 1], "uv": [26, 33]}
]
},
{
@ -96,7 +96,7 @@
"parent": "Balliste",
"pivot": [0, 0, 5.2],
"cubes": [
{"origin": [0.07, 22, 5.2], "size": [0.03, 1, 21], "uv": [44, 5]}
{"origin": [0.07, 14, 5.2], "size": [0.03, 1, 21], "uv": [44, 5]}
]
},
{
@ -104,7 +104,7 @@
"parent": "Balliste",
"pivot": [0, 0, -3],
"cubes": [
{"origin": [-0.9, 22.4, 3.4], "size": [2, 1, 3], "uv": [0, 20]}
{"origin": [-0.9, 14.4, 3.4], "size": [2, 1, 3], "uv": [0, 20]}
]
},
{
@ -112,7 +112,7 @@
"parent": "Balliste",
"pivot": [-17.5, 23, 3.3],
"cubes": [
{"origin": [-17.5848, 22.5, 3.31489], "size": [18, 1, 0.03], "uv": [0, 32]}
{"origin": [-17.5848, 14.5, 3.31489], "size": [18, 1, 0.03], "uv": [0, 32]}
]
},
{
@ -120,17 +120,17 @@
"parent": "Balliste",
"pivot": [17.6, 22.5, 3.3],
"cubes": [
{"origin": [-0.4152, 22.5, 3.31489], "size": [18, 1, 0.03], "uv": [0, 31]}
{"origin": [-0.4152, 14.5, 3.31489], "size": [18, 1, 0.03], "uv": [0, 31]}
]
},
{
"name": "BallistaArrow",
"pivot": [0, 20, 0],
"cubes": [
{"origin": [-31.4, 20.5, 17.2], "size": [34, 5, 0.03], "pivot": [0.1, 23, 17.2], "rotation": [0, -90, -45], "uv": [0, 72]},
{"origin": [-31.4, 20.5, 17.2], "size": [34, 5, 0.03], "pivot": [0.1, 23, 17.2], "rotation": [0, -90, 45], "uv": [0, 72]},
{"origin": [-34.4, 21, 17.2], "size": [4, 4, 0.03], "pivot": [0.1, 23, 17.2], "rotation": [0, -90, 45], "uv": [76, 72]},
{"origin": [-34.4, 21, 17.2], "size": [4, 4, 0.03], "pivot": [0.1, 23, 17.2], "rotation": [0, -90, -45], "uv": [68, 72]}
{"origin": [-31.4, 15.5, 22.2], "size": [34, 5, 0.03], "pivot": [0.1, 23, 17.2], "rotation": [0, -90, -45], "uv": [0, 72]},
{"origin": [-31.4, 15.5, 12.2], "size": [34, 5, 0.03], "pivot": [0.1, 23, 17.2], "rotation": [0, -90, 45], "uv": [0, 72]},
{"origin": [-34.4, 16, 12.2], "size": [4, 4, 0.03], "pivot": [0.1, 23, 17.2], "rotation": [0, -90, 45], "uv": [76, 72]},
{"origin": [-34.4, 16, 22.2], "size": [4, 4, 0.03], "pivot": [0.1, 23, 17.2], "rotation": [0, -90, -45], "uv": [68, 72]}
]
}
]

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,150 @@
{
"format_version": "1.12.0",
"minecraft:geometry": [
{
"description": {
"identifier": "geometry.unknown",
"texture_width": 1024,
"texture_height": 1024,
"visible_bounds_width": 12,
"visible_bounds_height": 10.5,
"visible_bounds_offset": [0, 4.75, 0]
},
"bones": [
{
"name": "Structure",
"pivot": [0, 2, -36],
"cubes": [
{"origin": [14, 2, -156], "size": [2, 3, 195], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [199, 3]},
{"origin": [14.9, 70.50357, -37.38225], "size": [2, 3, 73], "pivot": [15, 72.00357, -28.88225], "rotation": [-90, 0, 0], "uv": [0, 76]},
{"origin": [13.9, 68.50357, 34.61775], "size": [4, 68, 5], "pivot": [15, 72.00357, -28.88225], "rotation": [-90, 0, 0], "uv": [18, 76]},
{"origin": [-18.1, 68.50357, 34.61775], "size": [4, 68, 5], "pivot": [15, 72.00357, -28.88225], "rotation": [-90, 0, 0], "uv": [0, 76]},
{"origin": [-17.1, 70.50357, -37.38225], "size": [2, 3, 73], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, 0], "uv": [0, 0]},
{"origin": [-16.9, 71.50357, -29.38225], "size": [2, 1, 45], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -45], "uv": [199, 0]},
{"origin": [-48.9, 71.00357, -29.38225], "size": [2, 2, 31], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -90], "uv": [0, 33]},
{"origin": [-48.9, 71.00357, 0.61775], "size": [2, 33, 1], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -90], "uv": [115, 0]},
{"origin": [1, 7.60357, -13.88225], "size": [2, 43, 1], "pivot": [15, 39.10357, -13.38225], "rotation": [-90, 45, -90], "uv": [67, 93]},
{"origin": [-3, 7.60357, -13.88225], "size": [2, 43, 1], "pivot": [-15, 39.10357, -13.38225], "rotation": [-90, -45, 90], "uv": [67, 0]},
{"origin": [-48.9, 71.00357, -29.38225], "size": [2, 33, 1], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -90], "uv": [109, 0]},
{"origin": [-81.9, 71.00357, -36.38225], "size": [2, 2, 45], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -90], "uv": [0, 198]},
{"origin": [-81.9, 100.00357, -36.38225], "size": [2, 2, 45], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -90], "uv": [77, 76]},
{"origin": [-81.9, 128.00357, -36.38225], "size": [2, 2, 45], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -90], "uv": [77, 0]},
{"origin": [-16.9, 71.00357, -29.38225], "size": [2, 2, 31], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -90], "uv": [0, 0]},
{"origin": [-61.9, 71.40357, -74.38225], "size": [2, 1, 43], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -135], "uv": [199, 46]},
{"origin": [59.9, 71.50357, -74.38225], "size": [2, 1, 43], "pivot": [15, 72.00357, -28.88225], "rotation": [-90, 0, 135], "uv": [49, 198]},
{"origin": [14.9, 71.40357, -29.38225], "size": [2, 1, 45], "pivot": [15, 72.00357, -28.88225], "rotation": [-90, 0, 45], "uv": [94, 198]},
{"origin": [-14, 3, 31], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 33]},
{"origin": [-14, 3, 23], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 30]},
{"origin": [-14, 3, 7], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 24]},
{"origin": [-14, 3, 15], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 27]},
{"origin": [-14, 3, -1], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 12]},
{"origin": [-14, 3, -9], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 15]},
{"origin": [-14, 3, -17], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 18]},
{"origin": [-14, 3, -25], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 21]},
{"origin": [-14, 3, -33], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 0]},
{"origin": [-14, 3, -41], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 3]},
{"origin": [-14, 3, -49], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 6]},
{"origin": [-14, 3, -57], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 9]},
{"origin": [-14, 3, -65], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 62]},
{"origin": [-14, 3, -73], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 65]},
{"origin": [-14, 3, -81], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 68]},
{"origin": [-14, 3, -89], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 123]},
{"origin": [-14, 3, -97], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 50]},
{"origin": [-14, 3, -105], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 53]},
{"origin": [-14, 3, -113], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 56]},
{"origin": [-14, 3, -121], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 59]},
{"origin": [-14, 3, -129], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [0, 69]},
{"origin": [-14, 3, -137], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 47]},
{"origin": [-14, 3, -145], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [0, 66]},
{"origin": [-16, 2, -156], "size": [2, 3, 195], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [0, 198]},
{"origin": [-0.5, 2, -156], "size": [2, 3, 195], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [0, 0]}
]
},
{
"name": "Wheel1",
"parent": "Structure",
"pivot": [20, 6, -28.8],
"cubes": [
{"origin": [18.5, 11.5, -31.3], "size": [3, 1, 5], "uv": [116, 126]},
{"origin": [18.5, 10.5, -33.3], "size": [3, 1, 9], "uv": [135, 47]},
{"origin": [18.5, 8.5, -34.3], "size": [3, 2, 11], "uv": [36, 120]},
{"origin": [18.5, 3.5, -35.3], "size": [3, 5, 13], "uv": [77, 76]},
{"origin": [18.5, 1.5, -34.3], "size": [3, 2, 11], "uv": [77, 107]},
{"origin": [18.5, 0.5, -33.3], "size": [3, 1, 9], "uv": [36, 133]},
{"origin": [18.5, -0.5, -31.3], "size": [3, 1, 5], "uv": [92, 126]}
]
},
{
"name": "Wheel2",
"parent": "Structure",
"pivot": [20, 6, 0.2],
"cubes": [
{"origin": [18.5, 11.5, -2.3], "size": [3, 1, 5], "uv": [104, 89]},
{"origin": [18.5, 10.5, -4.3], "size": [3, 1, 9], "uv": [125, 126]},
{"origin": [18.5, 8.5, -5.3], "size": [3, 2, 11], "uv": [94, 96]},
{"origin": [18.5, 3.5, -6.3], "size": [3, 5, 13], "uv": [77, 18]},
{"origin": [18.5, 1.5, -5.3], "size": [3, 2, 11], "uv": [36, 107]},
{"origin": [18.5, 0.5, -4.3], "size": [3, 1, 9], "uv": [128, 62]},
{"origin": [18.5, -0.5, -2.3], "size": [3, 1, 5], "uv": [126, 36]}
]
},
{
"name": "Wheel3",
"parent": "Structure",
"pivot": [20, 6, 27.9],
"cubes": [
{"origin": [18.5, 11.5, 25.4], "size": [3, 1, 5], "uv": [88, 37]},
{"origin": [18.5, 10.5, 23.4], "size": [3, 1, 9], "uv": [101, 126]},
{"origin": [18.5, 8.5, 22.4], "size": [3, 2, 11], "uv": [36, 94]},
{"origin": [18.5, 3.5, 21.4], "size": [3, 5, 13], "uv": [77, 0]},
{"origin": [18.5, 1.5, 22.4], "size": [3, 2, 11], "uv": [77, 94]},
{"origin": [18.5, 0.5, 23.4], "size": [3, 1, 9], "uv": [126, 106]},
{"origin": [18.5, -0.5, 25.4], "size": [3, 1, 5], "uv": [99, 36]}
]
},
{
"name": "Wheel4",
"parent": "Structure",
"pivot": [-20, 6, -28.8],
"cubes": [
{"origin": [-21.5, 11.5, -31.3], "size": [3, 1, 5], "uv": [52, 51]},
{"origin": [-21.5, 10.5, -33.3], "size": [3, 1, 9], "uv": [96, 76]},
{"origin": [-21.5, 8.5, -34.3], "size": [3, 2, 11], "uv": [0, 0]},
{"origin": [-21.5, 3.5, -35.3], "size": [3, 5, 13], "uv": [35, 0]},
{"origin": [-21.5, 1.5, -34.3], "size": [3, 2, 11], "uv": [0, 13]},
{"origin": [-21.5, 0.5, -33.3], "size": [3, 1, 9], "uv": [96, 111]},
{"origin": [-21.5, -0.5, -31.3], "size": [3, 1, 5], "uv": [54, 39]}
]
},
{
"name": "Wheel5",
"parent": "Structure",
"pivot": [-20, 6, 0.2],
"cubes": [
{"origin": [-21.5, 11.5, -2.3], "size": [3, 1, 5], "uv": [55, 76]},
{"origin": [-21.5, 10.5, -4.3], "size": [3, 1, 9], "uv": [77, 126]},
{"origin": [-21.5, 8.5, -5.3], "size": [3, 2, 11], "uv": [35, 18]},
{"origin": [-21.5, 3.5, -6.3], "size": [3, 5, 13], "uv": [35, 33]},
{"origin": [-21.5, 1.5, -5.3], "size": [3, 2, 11], "uv": [0, 33]},
{"origin": [-21.5, 0.5, -4.3], "size": [3, 1, 9], "uv": [126, 76]},
{"origin": [-21.5, -0.5, -2.3], "size": [3, 1, 5], "uv": [55, 67]}
]
},
{
"name": "Wheel6",
"parent": "Structure",
"pivot": [-20, 6, 27.9],
"cubes": [
{"origin": [-21.5, 11.5, 25.4], "size": [3, 1, 5], "uv": [55, 82]},
{"origin": [-21.5, 10.5, 23.4], "size": [3, 1, 9], "uv": [126, 96]},
{"origin": [-21.5, 8.5, 22.4], "size": [3, 2, 11], "uv": [35, 51]},
{"origin": [-21.5, 3.5, 21.4], "size": [3, 5, 13], "uv": [36, 76]},
{"origin": [-21.5, 1.5, 22.4], "size": [3, 2, 11], "uv": [0, 46]},
{"origin": [-21.5, 0.5, 23.4], "size": [3, 1, 9], "uv": [126, 86]},
{"origin": [-21.5, -0.5, 25.4], "size": [3, 1, 5], "uv": [77, 36]}
]
}
]
}
]
}

View File

@ -0,0 +1,150 @@
{
"format_version": "1.12.0",
"minecraft:geometry": [
{
"description": {
"identifier": "geometry.unknown",
"texture_width": 1024,
"texture_height": 1024,
"visible_bounds_width": 12,
"visible_bounds_height": 10.5,
"visible_bounds_offset": [0, 4.75, 0]
},
"bones": [
{
"name": "Structure",
"pivot": [0, 2, -36],
"cubes": [
{"origin": [14, 2, -156], "size": [2, 3, 195], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [199, 3]},
{"origin": [14.9, 70.50357, -37.38225], "size": [2, 3, 73], "pivot": [15, 72.00357, -28.88225], "rotation": [-90, 0, 0], "uv": [0, 76]},
{"origin": [13.9, 68.50357, 34.61775], "size": [4, 68, 5], "pivot": [15, 72.00357, -28.88225], "rotation": [-90, 0, 0], "uv": [18, 76]},
{"origin": [-18.1, 68.50357, 34.61775], "size": [4, 68, 5], "pivot": [15, 72.00357, -28.88225], "rotation": [-90, 0, 0], "uv": [0, 76]},
{"origin": [-17.1, 70.50357, -37.38225], "size": [2, 3, 73], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, 0], "uv": [0, 0]},
{"origin": [-16.9, 71.50357, -29.38225], "size": [2, 1, 45], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -45], "uv": [199, 0]},
{"origin": [-48.9, 71.00357, -29.38225], "size": [2, 2, 31], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -90], "uv": [0, 33]},
{"origin": [-48.9, 71.00357, 0.61775], "size": [2, 33, 1], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -90], "uv": [115, 0]},
{"origin": [1, 7.60357, -13.88225], "size": [2, 43, 1], "pivot": [15, 39.10357, -13.38225], "rotation": [-90, 45, -90], "uv": [67, 93]},
{"origin": [-3, 7.60357, -13.88225], "size": [2, 43, 1], "pivot": [-15, 39.10357, -13.38225], "rotation": [-90, -45, 90], "uv": [67, 0]},
{"origin": [-48.9, 71.00357, -29.38225], "size": [2, 33, 1], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -90], "uv": [109, 0]},
{"origin": [-81.9, 71.00357, -36.38225], "size": [2, 2, 45], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -90], "uv": [0, 198]},
{"origin": [-81.9, 100.00357, -36.38225], "size": [2, 2, 45], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -90], "uv": [77, 76]},
{"origin": [-81.9, 128.00357, -36.38225], "size": [2, 2, 45], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -90], "uv": [77, 0]},
{"origin": [-16.9, 71.00357, -29.38225], "size": [2, 2, 31], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -90], "uv": [0, 0]},
{"origin": [-61.9, 71.40357, -74.38225], "size": [2, 1, 43], "pivot": [-15, 72.00357, -28.88225], "rotation": [-90, 0, -135], "uv": [199, 46]},
{"origin": [59.9, 71.50357, -74.38225], "size": [2, 1, 43], "pivot": [15, 72.00357, -28.88225], "rotation": [-90, 0, 135], "uv": [49, 198]},
{"origin": [14.9, 71.40357, -29.38225], "size": [2, 1, 45], "pivot": [15, 72.00357, -28.88225], "rotation": [-90, 0, 45], "uv": [94, 198]},
{"origin": [-14, 3, 31], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 33]},
{"origin": [-14, 3, 23], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 30]},
{"origin": [-14, 3, 7], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 24]},
{"origin": [-14, 3, 15], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 27]},
{"origin": [-14, 3, -1], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 12]},
{"origin": [-14, 3, -9], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 15]},
{"origin": [-14, 3, -17], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 18]},
{"origin": [-14, 3, -25], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 21]},
{"origin": [-14, 3, -33], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 0]},
{"origin": [-14, 3, -41], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 3]},
{"origin": [-14, 3, -49], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 6]},
{"origin": [-14, 3, -57], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [126, 9]},
{"origin": [-14, 3, -65], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 62]},
{"origin": [-14, 3, -73], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 65]},
{"origin": [-14, 3, -81], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 68]},
{"origin": [-14, 3, -89], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 123]},
{"origin": [-14, 3, -97], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 50]},
{"origin": [-14, 3, -105], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 53]},
{"origin": [-14, 3, -113], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 56]},
{"origin": [-14, 3, -121], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 59]},
{"origin": [-14, 3, -129], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [0, 69]},
{"origin": [-14, 3, -137], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [77, 47]},
{"origin": [-14, 3, -145], "size": [28, 1, 2], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [0, 66]},
{"origin": [-16, 2, -156], "size": [2, 3, 195], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [0, 198]},
{"origin": [-0.5, 2, -156], "size": [2, 3, 195], "pivot": [16.5, 2, 39], "rotation": [-45, 0, 0], "uv": [0, 0]}
]
},
{
"name": "Wheel1",
"parent": "Structure",
"pivot": [20, 6, -28.8],
"cubes": [
{"origin": [18.5, 11.5, -31.3], "size": [3, 1, 5], "uv": [116, 126]},
{"origin": [18.5, 10.5, -33.3], "size": [3, 1, 9], "uv": [135, 47]},
{"origin": [18.5, 8.5, -34.3], "size": [3, 2, 11], "uv": [36, 120]},
{"origin": [18.5, 3.5, -35.3], "size": [3, 5, 13], "uv": [77, 76]},
{"origin": [18.5, 1.5, -34.3], "size": [3, 2, 11], "uv": [77, 107]},
{"origin": [18.5, 0.5, -33.3], "size": [3, 1, 9], "uv": [36, 133]},
{"origin": [18.5, -0.5, -31.3], "size": [3, 1, 5], "uv": [92, 126]}
]
},
{
"name": "Wheel2",
"parent": "Structure",
"pivot": [20, 6, 0.2],
"cubes": [
{"origin": [18.5, 11.5, -2.3], "size": [3, 1, 5], "uv": [104, 89]},
{"origin": [18.5, 10.5, -4.3], "size": [3, 1, 9], "uv": [125, 126]},
{"origin": [18.5, 8.5, -5.3], "size": [3, 2, 11], "uv": [94, 96]},
{"origin": [18.5, 3.5, -6.3], "size": [3, 5, 13], "uv": [77, 18]},
{"origin": [18.5, 1.5, -5.3], "size": [3, 2, 11], "uv": [36, 107]},
{"origin": [18.5, 0.5, -4.3], "size": [3, 1, 9], "uv": [128, 62]},
{"origin": [18.5, -0.5, -2.3], "size": [3, 1, 5], "uv": [126, 36]}
]
},
{
"name": "Wheel3",
"parent": "Structure",
"pivot": [20, 6, 27.9],
"cubes": [
{"origin": [18.5, 11.5, 25.4], "size": [3, 1, 5], "uv": [88, 37]},
{"origin": [18.5, 10.5, 23.4], "size": [3, 1, 9], "uv": [101, 126]},
{"origin": [18.5, 8.5, 22.4], "size": [3, 2, 11], "uv": [36, 94]},
{"origin": [18.5, 3.5, 21.4], "size": [3, 5, 13], "uv": [77, 0]},
{"origin": [18.5, 1.5, 22.4], "size": [3, 2, 11], "uv": [77, 94]},
{"origin": [18.5, 0.5, 23.4], "size": [3, 1, 9], "uv": [126, 106]},
{"origin": [18.5, -0.5, 25.4], "size": [3, 1, 5], "uv": [99, 36]}
]
},
{
"name": "Wheel4",
"parent": "Structure",
"pivot": [-20, 6, -28.8],
"cubes": [
{"origin": [-21.5, 11.5, -31.3], "size": [3, 1, 5], "uv": [52, 51]},
{"origin": [-21.5, 10.5, -33.3], "size": [3, 1, 9], "uv": [96, 76]},
{"origin": [-21.5, 8.5, -34.3], "size": [3, 2, 11], "uv": [0, 0]},
{"origin": [-21.5, 3.5, -35.3], "size": [3, 5, 13], "uv": [35, 0]},
{"origin": [-21.5, 1.5, -34.3], "size": [3, 2, 11], "uv": [0, 13]},
{"origin": [-21.5, 0.5, -33.3], "size": [3, 1, 9], "uv": [96, 111]},
{"origin": [-21.5, -0.5, -31.3], "size": [3, 1, 5], "uv": [54, 39]}
]
},
{
"name": "Wheel5",
"parent": "Structure",
"pivot": [-20, 6, 0.2],
"cubes": [
{"origin": [-21.5, 11.5, -2.3], "size": [3, 1, 5], "uv": [55, 76]},
{"origin": [-21.5, 10.5, -4.3], "size": [3, 1, 9], "uv": [77, 126]},
{"origin": [-21.5, 8.5, -5.3], "size": [3, 2, 11], "uv": [35, 18]},
{"origin": [-21.5, 3.5, -6.3], "size": [3, 5, 13], "uv": [35, 33]},
{"origin": [-21.5, 1.5, -5.3], "size": [3, 2, 11], "uv": [0, 33]},
{"origin": [-21.5, 0.5, -4.3], "size": [3, 1, 9], "uv": [126, 76]},
{"origin": [-21.5, -0.5, -2.3], "size": [3, 1, 5], "uv": [55, 67]}
]
},
{
"name": "Wheel6",
"parent": "Structure",
"pivot": [-20, 6, 27.9],
"cubes": [
{"origin": [-21.5, 11.5, 25.4], "size": [3, 1, 5], "uv": [55, 82]},
{"origin": [-21.5, 10.5, 23.4], "size": [3, 1, 9], "uv": [126, 96]},
{"origin": [-21.5, 8.5, 22.4], "size": [3, 2, 11], "uv": [35, 51]},
{"origin": [-21.5, 3.5, 21.4], "size": [3, 5, 13], "uv": [36, 76]},
{"origin": [-21.5, 1.5, 22.4], "size": [3, 2, 11], "uv": [0, 46]},
{"origin": [-21.5, 0.5, 23.4], "size": [3, 1, 9], "uv": [126, 86]},
{"origin": [-21.5, -0.5, 25.4], "size": [3, 1, 5], "uv": [77, 36]}
]
}
]
}
]
}

View File

@ -5,6 +5,7 @@
"item.siegemachines.catapult": "Catapult",
"item.siegemachines.ballista": "Ballista",
"item.siegemachines.battering_ram": "Battering Ram",
"item.siegemachines.siege_ladder": "Siege Ladder",
"item.siegemachines.cannonball": "Cannonball",
"item.siegemachines.giant_arrow": "Giant Arrow",
"item.siegemachines.stone": "Stone",
@ -26,13 +27,17 @@
"itemGroup.siegemachines.medieval_siege_machines": "Medieval Siege Machines",
"siegemachines.uses_gunpowder": "Uses Gunpowder",
"siegemachines.uses_gunpowder": "Gunpowder Required",
"siegemachines.ammo": "Ammo:",
"siegemachines.category": "Medieval Siege Machines",
"siegemachines.machine_use": "Use Machine",
"siegemachines.ladder_climb": "Start climbing the ladder",
"siegemachines.machine_inventory": "Open Inventory",
"siegemachines.no_ammo": "No ammo!",
"siegemachines.no_gunpowder": "No gunpowder!",
"siegemachines.wait": "Wait %1$f seconds.",
"category.siegemachines.siege_workbench_crafting": "Crafting"
"category.siegemachines.siege_workbench_crafting": "Crafting",
"siegemachines.usage": "Press %1$s to use the engine"
}

View File

@ -5,6 +5,7 @@
"item.siegemachines.catapult": "Катапульта",
"item.siegemachines.ballista": "Баллиста",
"item.siegemachines.battering_ram": "Таран",
"item.siegemachines.siege_ladder": "Осадная лестница",
"item.siegemachines.cannonball": "Пушечное ядро",
"item.siegemachines.giant_arrow": "Гигантская стрела",
"item.siegemachines.stone": "Валун",
@ -28,9 +29,13 @@
"siegemachines.ammo": "Боеприпасы:",
"siegemachines.category": "Medieval Siege Machines",
"siegemachines.machine_use": "Использовать машину",
"siegemachines.ladder_climb": "Начать поднматься по лестнице",
"siegemachines.machine_inventory": "Открыть инвентарь",
"siegemachines.no_ammo": "Нет боеприпасов!",
"siegemachines.no_gunpowder":"Нет пороха!",
"siegemachines.wait": "Ждите %1$f секунд.",
"category.siegemachines.siege_workbench_crafting": "Крафт"
"category.siegemachines.siege_workbench_crafting": "Крафт",
"siegemachines.usage": "Нажми %1$s, чтобы использовать осадное орудие"
}

View File

@ -0,0 +1,75 @@
{
"credit": "Made with Blockbench",
"parent": "builtin/entity",
"gui_light": "side",
"texture_size": [
256,
256
],
"display": {
"thirdperson_righthand": {
"scale": [
0.23,
0.23,
0.23
]
},
"thirdperson_lefthand": {
"scale": [
0.23,
0.23,
0.23
]
},
"firstperson_righthand": {
"scale": [
0.23,
0.23,
0.23
]
},
"firstperson_lefthand": {
"scale": [
0.23,
0.23,
0.23
]
},
"ground": {
"scale": [
0.23,
0.23,
0.23
]
},
"gui": {
"rotation": [
29,
126,
0
],
"translation": [
-1,
-3.25,
0
],
"scale": [
0.27,
0.27,
0.27
]
},
"fixed": {
"translation": [
0,
-3,
-2
],
"scale": [
0.23,
0.23,
0.23
]
}
}
}

View File

@ -0,0 +1,48 @@
{
"credit": "Made with Blockbench",
"textures": {
"0": "siegemachines:entity/stone",
"particle": "siegemachines:entity/stone"
},
"elements": [
{
"from": [-7, -7, -7],
"to": [23, 23, 23],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]},
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#0"},
"east": {"uv": [0, 0, 16, 16], "texture": "#0"},
"south": {"uv": [0, 0, 16, 16], "texture": "#0"},
"west": {"uv": [0, 0, 16, 16], "texture": "#0"},
"up": {"uv": [0, 0, 16, 16], "texture": "#0"},
"down": {"uv": [0, 0, 16, 16], "texture": "#0"}
}
}
],
"display": {
"thirdperson_righthand": {
"rotation": [18, 0, 0],
"translation": [-6, 5, 1]
},
"thirdperson_lefthand": {
"rotation": [18, 0, 0],
"translation": [-6, 5, 1]
},
"firstperson_righthand": {
"translation": [-9, 0, 0]
},
"firstperson_lefthand": {
"translation": [-9, 0, 0]
},
"ground": {
"scale": [0.5, 0.5, 0.5]
},
"gui": {
"rotation": [45, -45, 0],
"scale": [0.5, 0.5, 0.5]
},
"fixed": {
"scale": [0.5, 0.5, 0.5]
}
}
}

View File

@ -0,0 +1,79 @@
{
"credit": "Made with Blockbench",
"parent": "builtin/entity",
"texture_size": [
512,
512
],
"display": {
"thirdperson_righthand": {
"scale": [
0.1,
0.1,
0.1
]
},
"thirdperson_lefthand": {
"scale": [
0.1,
0.1,
0.1
]
},
"firstperson_righthand": {
"scale": [
0.1,
0.1,
0.1
]
},
"firstperson_lefthand": {
"scale": [
0.1,
0.1,
0.1
]
},
"ground": {
"scale": [
0.1,
0.1,
0.1
]
},
"gui": {
"rotation": [
29,
126,
0
],
"translation": [
0.25,
-4,
0
],
"scale": [
0.155,
0.155,
0.155
]
},
"fixed": {
"rotation": [
0,
90,
0
],
"translation": [
0,
-3,
-2.25
],
"scale": [
0.1,
0.1,
0.1
]
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -2,7 +2,8 @@
"type": "siegemachines:siege_workbench",
"pattern": [
"bsb",
"ibi"
"ibi",
" "
],
"key": {
"b": {

View File

@ -0,0 +1,42 @@
{
"type": "siegemachines:siege_workbench",
"pattern": [
"mb ",
"pBi",
"lw "
],
"key": {
"m": {
"item": "siegemachines:barrel",
"count": 1
},
"B": {
"item": "siegemachines:turret_base",
"count": 7
},
"b": {
"item": "siegemachines:beam",
"count": 12
},
"p": {
"tag": "minecraft:planks",
"count": 1
},
"i": {
"tag": "forge:ingots/iron",
"count": 19
},
"l": {
"item": "minecraft:leather",
"count": 4
},
"w": {
"item": "siegemachines:wheel",
"count": 2
}
},
"result": {
"item": "siegemachines:culverin",
"count": 1
}
}

View File

@ -1,9 +1,9 @@
{
"type": "siegemachines:siege_workbench",
"pattern": [
"i",
"s",
"f"
" i ",
" s ",
" f "
],
"key": {
"i": {

View File

@ -0,0 +1,30 @@
{
"type": "siegemachines:siege_workbench",
"pattern": [
"l ",
"bl ",
"wBl"
],
"key": {
"B": {
"item": "siegemachines:turret_base",
"count": 8
},
"b": {
"item": "siegemachines:beam",
"count": 20
},
"l": {
"item": "minecraft:ladder",
"count": 4
},
"w": {
"item": "siegemachines:wheel",
"count": 6
}
},
"result": {
"item": "siegemachines:siege_ladder",
"count": 1
}
}

View File

@ -1,7 +1,8 @@
{
"type": "siegemachines:siege_workbench",
"pattern": [
"bp"
"bp",
" "
],
"key": {
"b": {