Something something porting go brr...

This commit is contained in:
Flanks255 2024-07-22 18:42:48 -05:00
parent ac320235a2
commit 98ef8e8332
6 changed files with 42 additions and 41 deletions

View file

@ -6,7 +6,7 @@ mod_version=1.2.14
# Forge
game_version=1.21
neo_version=21.0.76-beta
neo_version=21.0.79-beta
# mods.toml
loader=4

View file

@ -28,7 +28,6 @@ import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.BlockHitResult;
import net.neoforged.neoforge.common.PlantType;
import net.neoforged.neoforge.items.ItemHandlerHelper;
import java.util.List;
@ -52,10 +51,10 @@ public class BlockPlant extends CropBlock {
// this.returnMeta = returnMeta;
}
@Override
/* @Override
public PlantType getPlantType(BlockGetter world, BlockPos pos) {
return PlantType.CROP;
}
}*/
//
// @Override
// public int damageDropped(BlockState state) {

View file

@ -9,14 +9,15 @@ import net.minecraft.world.item.Tier;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.item.enchantment.Enchantment;
import net.neoforged.neoforge.common.ItemAbilities;
import net.neoforged.neoforge.common.ToolAction;
import net.neoforged.neoforge.common.ItemAbility;
import javax.annotation.Nonnull;
import java.util.List;
public class AllInOneTool extends DiggerItem {
private final Tier tier;
private static List<ToolAction> ACTIONS = List.of(
private static List<ItemAbility> ACTIONS = List.of(
ItemAbilities.AXE_DIG,
ItemAbilities.HOE_DIG,
ItemAbilities.PICKAXE_DIG,
@ -28,8 +29,8 @@ public class AllInOneTool extends DiggerItem {
public AllInOneTool(Tier tier) {
super(
4.0f,
-2f,
/* 4.0f,
-2f,*/
tier,
ActuallyTags.Blocks.MINEABLE_WITH_AIO,
new Properties()
@ -41,12 +42,13 @@ public class AllInOneTool extends DiggerItem {
}
@Override
public boolean canPerformAction(ItemStack stack, ToolAction toolAction) {
public boolean canPerformAction(@Nonnull ItemStack stack, @Nonnull ItemAbility toolAction) {
if (ACTIONS.contains(toolAction))
return true;
return super.canPerformAction(stack, toolAction);
}
@Nonnull
@Override
public InteractionResult useOn(UseOnContext context) {
// How, no idea, possible, most likely :cry:
@ -64,8 +66,8 @@ public class AllInOneTool extends DiggerItem {
return Items.IRON_HOE.useOn(context);
}
@Override
/* @Override //TODO help, enchantments are weird now.
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment) {
return super.canApplyAtEnchantingTable(stack, enchantment) || enchantment.category.canEnchant(Items.DIAMOND_SWORD);
}
}*/
}

View file

@ -37,7 +37,7 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.storage.loot.LootParams;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.common.IPlantable;
import net.neoforged.neoforge.common.SpecialPlantable;
import net.neoforged.neoforge.common.util.FakePlayerFactory;
import java.util.ArrayList;
@ -148,10 +148,10 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
}
private BlockState getPlantablePlantFromStack(ItemStack stack, Level world, BlockPos pos) {
if (StackUtil.isValid(stack)) {
IPlantable plantable = this.getPlantableFromStack(stack);
if (!stack.isEmpty()) {
SpecialPlantable plantable = this.getPlantableFromStack(stack);
if (plantable != null) {
BlockState state = plantable.g(world, pos);
BlockState state = plantable.getPlantType(world, pos);
if (state != null && state.getBlock() instanceof BonemealableBlock) {
return state;
}
@ -160,14 +160,14 @@ public class DefaultFarmerBehavior implements IFarmerBehavior {
return null;
}
private IPlantable getPlantableFromStack(ItemStack stack) {
private SpecialPlantable getPlantableFromStack(ItemStack stack) {
Item item = stack.getItem();
if (item instanceof IPlantable) {
return (IPlantable) item;
if (item instanceof SpecialPlantable plantable) {
return plantable;
} else if (item instanceof BlockItem) {
Block block = Block.byItem(item);
if (block instanceof IPlantable) {
return (IPlantable) block;
if (block instanceof SpecialPlantable plantable) {
return plantable;
}
}
return null;

View file

@ -27,7 +27,6 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.storage.loot.LootParams;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.common.IPlantable;
import java.util.List;

View file

@ -40,6 +40,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemDisplayContext;
@ -59,7 +60,7 @@ public final class AssetUtil {
public static final int MAX_LIGHT_Y = 0xF000F0;
public static final ResourceLocation GUI_INVENTORY_LOCATION = getGuiLocation("gui_inventory");
private static final ResourceLocation FORGE_WHITE = ResourceLocation.tryParse("forge", "white");
private static final ResourceLocation FORGE_WHITE = ResourceLocation.tryBuild("forge", "white");
public static ResourceLocation getGuiLocation(String file) {
return ActuallyAdditions.modLoc("textures/gui/" + file + ".png");
@ -224,7 +225,7 @@ public final class AssetUtil {
// GlStateManager._popMatrix();
// }
public static void spawnLaserWithTimeServer(Level world, double startX, double startY, double startZ, double endX, double endY, double endZ, int color, int maxAge, double rotationTime, float size, float alpha) {
public static void spawnLaserWithTimeServer(ServerLevel world, double startX, double startY, double startZ, double endX, double endY, double endZ, int color, int maxAge, double rotationTime, float size, float alpha) {
if (!world.isClientSide) {
CompoundTag data = new CompoundTag();
data.putDouble("StartX", startX);
@ -238,7 +239,7 @@ public final class AssetUtil {
data.putFloat("Size", size);
data.putInt("MaxAge", maxAge);
data.putFloat("Alpha", alpha);
PacketDistributor.NEAR.with(new PacketDistributor.TargetPoint(startX, startY, startZ, 96, world.dimension())).send(new PacketServerToClient(data, PacketHandler.LASER_HANDLER));
PacketDistributor.sendToPlayersNear(world, null, startX, startY, startZ, 96, new PacketServerToClient(data, PacketHandler.LASER_HANDLER));
}
}
@ -292,25 +293,25 @@ public final class AssetUtil {
for (int i = 1; i < 4; i++) {
float width = beamWidth * (i / 4.0f);
//top
builder.vertex(matrix, -width, width, 0.0f).color(r, g, b, a).uv(minU, maxV).uv2(lightmap).endVertex();
builder.vertex(matrix, width, width, 0.0f).color(r, g, b, a).uv(maxU, maxV).uv2(lightmap).endVertex();
builder.vertex(matrix, width, width, -length).color(r, g, b, a).uv(maxU, minV).uv2(lightmap).endVertex();
builder.vertex(matrix, -width, width, -length).color(r, g, b, a).uv(minU, minV).uv2(lightmap).endVertex();
builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a).setUv(minU, maxV).setLight(lightmap);//.endVertex(); //TODO ?!
builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);//.endVertex();
builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a).setUv(maxU, minV).setLight(lightmap);
builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
//bottom
builder.vertex(matrix, -width, -width, 0.0f).color(r, g, b, a).uv(minU, maxV).uv2(lightmap).endVertex();
builder.vertex(matrix, -width, -width, -length).color(r, g, b, a).uv(minU, minV).uv2(lightmap).endVertex();
builder.vertex(matrix, width, -width, -length).color(r, g, b, a).uv(maxU, minV).uv2(lightmap).endVertex();
builder.vertex(matrix, width, -width, 0.0f).color(r, g, b, a).uv(maxU, maxV).uv2(lightmap).endVertex();
builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a).setUv(minU, maxV).setLight(lightmap);
builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a).setUv(maxU, minV).setLight(lightmap);
builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
//left
builder.vertex(matrix, -width, width, 0.0f).color(r, g, b, a).uv(maxU, maxV).uv2(lightmap).endVertex();
builder.vertex(matrix, -width, -width, 0.0f).color(r, g, b, a).uv(maxU, maxV).uv2(lightmap).endVertex();
builder.vertex(matrix, -width, -width, -length).color(r, g, b, a).uv(minU, minV).uv2(lightmap).endVertex();
builder.vertex(matrix, -width, width, -length).color(r, g, b, a).uv(minU, minV).uv2(lightmap).endVertex();
builder.addVertex(matrix, -width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
builder.addVertex(matrix, -width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
builder.addVertex(matrix, -width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
builder.addVertex(matrix, -width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
//right
builder.vertex(matrix, width, width, 0.0f).color(r, g, b, a).uv(maxU, maxV).uv2(lightmap).endVertex();
builder.vertex(matrix, width, -width, 0.0f).color(r, g, b, a).uv(maxU, maxV).uv2(lightmap).endVertex();
builder.vertex(matrix, width, -width, -length).color(r, g, b, a).uv(minU, minV).uv2(lightmap).endVertex();
builder.vertex(matrix, width, width, -length).color(r, g, b, a).uv(minU, minV).uv2(lightmap).endVertex();
builder.addVertex(matrix, width, width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
builder.addVertex(matrix, width, -width, 0.0f).setColor(r, g, b, a).setUv(maxU, maxV).setLight(lightmap);
builder.addVertex(matrix, width, -width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
builder.addVertex(matrix, width, width, -length).setColor(r, g, b, a).setUv(minU, minV).setLight(lightmap);
}
@ -362,7 +363,7 @@ public final class AssetUtil {
Matrix4f matrix = matrixStack.last().pose();
RenderSystem.setShader(GameRenderer::getPositionColorLightmapShader);
Tesselator.getInstance().getBuilder().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_LIGHTMAP);
Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_LIGHTMAP);
TextureAtlasSprite sprite = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS).apply(FORGE_WHITE);
float minU = sprite.getU0();